diff --git a/src/Components copy/Blog.jsx b/src/Components copy/Blog.jsx new file mode 100644 index 0000000..c1ac055 --- /dev/null +++ b/src/Components copy/Blog.jsx @@ -0,0 +1,68 @@ +import { useEffect, useState } from "react"; +import Navbar from "./Navbar"; +import axios from "axios"; +import { useParams } from "react-router-dom"; +import moment from "moment"; +import Footer from "./Footer"; +import { Loader } from "./Loader"; + +export default function Blog() { + const [blog, setBlog] = useState(null); + const params = useParams(); + useEffect(() => { + const fetchBlog = async () => { + await axios + .get( + `https://www.googleapis.com/blogger/v3/blogs/3771334625318012412/posts/${ + params.id + }?key=${import.meta.env.VITE_API_KEY}` + ) + .then((res) => setBlog(res.data)) + .catch((err) => err); + }; + fetchBlog(); + }, []); + return ( + <> + + {blog === null ? ( + + ) : ( +
+
+

+ {blog.title} +

+ +

+ {blog.author.displayName[0]} +

+
+ + Written By {blog.author.displayName} + + + {moment(blog.published).startOf("hour").fromNow()} + +
+
+
+

+

+
+ )} +