Skip to content

Commit

Permalink
Merge pull request #88 from Vipul-045/master
Browse files Browse the repository at this point in the history
News Page
  • Loading branch information
dinxsh authored Aug 13, 2024
2 parents eedbb66 + 84288e8 commit 5c69583
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 1 deletion.
Binary file added app/assets/NewsPageimg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/news/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import News from '../../components/News'

const page = async () => {
return(
<div className="flex flex-col mt-5 gap-7">
<div className="bg-cover bg-center bg-opacity-50 bg-[url(https://im.indiatimes.in/facebook/2019/Oct/mobile_gaming_1570096408.jpg)] w-full flex flex-col justify-center text-center items-center pl-7 h-[500px] gap-3">
<h1 className="text-5xl font-extrabold justify-center"> Welcome to {' '}
<span className='text-transparent bg-clip-text bg-gradient-to-r from-[#4F46E5] to-[#E114E5]'>
Esports News
</span> </h1>
<span className="auto text-md">Your Ultimate source for Esports News</span>
</div>
<News/>
</div>

)
}

export default page;
4 changes: 4 additions & 0 deletions components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const navLinks = [
title: "Blogs",
href: "/blogs",
},
{
title: "News",
href: "/news",
},
{
title: "About",
href: "/about",
Expand Down
37 changes: 37 additions & 0 deletions components/News.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use client";
import React, { useState, useEffect } from "react";
import axios from "axios";
import NewsItem from "./NewsItem";
import dotenv from "dotenv";

const News = () => {
const [articles, setArticles] = useState([]);

dotenv.config();

useEffect(() => {
const getArticles = async () => {
const response = await axios.get('https://newsapi.org/v2/everything?q=Gaming+Esports&from=2024-08-11&sortBy=publishedAt&language=en&apiKey=08573ce9567742189e61fdc2618a482b');
setArticles(response.data.articles);
};
getArticles();
}, [])

return (
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-8">
{articles.map((article) => {
return (
<NewsItem
title={article.title}
description={article.description}
url={article.url}
urlToImage={article.urlToImage}

/>
);
})}
</div>
);
};

export default News;
32 changes: 32 additions & 0 deletions components/NewsItem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";

const NewsItem = ({ title, description, url, urlToImage }) => {
return (
<div className="flex-1 p-6 md:p-10 z-10 overflow-auto">
<div className=" flex bg-black rounded-2xl border border-solid border-indigo-700 ">
<div className=" p-10 z-10 overflow-hidden">
<div className="min-h-96 ">
<div className="relative h-64">
<img
src={urlToImage}
alt={urlToImage}
className="w-full h-full rounded-sm object-cover"
/>
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black to-transparent h-24"></div>
</div>
<h3 className="text-2xl cursor-pointer font-bold mb-4 text-neon-green hover:text-white transition-colors duration-300 line-clamp-3">
<a href={url}>{title}</a>
</h3>
<p className="text-gray-300 mb-6 text-base line-clamp-4">
{description}
</p>
<a href={url} className="inline-flex items-center justify-center text-white py-2" >Read Full Article</a>
</div>
</div>
</div>
</div>
);
};


export default NewsItem;
3 changes: 2 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATABASE_URL="Mongo_DB_Connection_String/DB_Name"
MONGODB_URL=''
RESEND_API_KEY=''
NEXTAUTH_SECRET=''
NEXTAUTH_SECRET=''
NEWS_URL='https://newsapi.org/v2/everything?q=Esports&sortBy=publishedAt&language=en&apiKey=08573ce9567742189e61fdc2618a482b'

0 comments on commit 5c69583

Please sign in to comment.