-
Notifications
You must be signed in to change notification settings - Fork 0
/
SingleBlogPage.jsx
executable file
·44 lines (43 loc) · 1.51 KB
/
SingleBlogPage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import Header from "./components/Header/Header"
import Footer from './components/Footer/Footer';
import BlogsData from './BlogsData';
import { useParams } from "react-router-dom"
import SingleBlog from './components/SingleBlog/SingleBlog';
import EmptyList from './components/EmptyList/EmptyList';
export default function SingleBlogPage({isAuth, setIsAuth}){
const {id} = useParams();
const [blog, setBlog] = React.useState()
React.useEffect(
()=>{
let blog = BlogsData.find((blog)=>blog.id === parseInt(id))
if(blog){
setBlog(blog)
}
}, []
)
return (
<section>
{
blog ? (
// Single Blog Page JSX
<section>
<Header isAuth = {isAuth} setIsAuth = {setIsAuth}/>
<SingleBlog
title= {blog.title}
cover={blog.cover}
authorCover={blog.authorCover}
content={blog.content}
authorName={blog.authorName}
publishedDate={blog.publishedDate}
isAuth={isAuth}
blogCategory={blog.blogCategory}
blogId = {blog.id}
/>
<Footer/>
</section>
) : <EmptyList/>
}
</section>
);
}