diff --git a/app/blog/[slug]/page.js b/app/blog/[slug]/page.js new file mode 100644 index 00000000..59bf7bc9 --- /dev/null +++ b/app/blog/[slug]/page.js @@ -0,0 +1,25 @@ +// @flow strict +import { personalData } from "@/utils/data/personal-data"; + +async function getBlog(slug) { + const res = await fetch(`https://dev.to/api/articles/${personalData.devUsername}/${slug}`) + + if (!res.ok) { + throw new Error('Failed to fetch data') + } + + const data = await res.json(); + return data; +}; + +async function BlogDetails({params}) { + const slug = params.slug; + const blog = await getBlog(slug); + + return ( +
+
+ ); +}; + +export default BlogDetails; \ No newline at end of file diff --git a/app/blog/page.js b/app/blog/page.js index 5659880f..f649c605 100644 --- a/app/blog/page.js +++ b/app/blog/page.js @@ -3,7 +3,7 @@ import { personalData } from "@/utils/data/personal-data"; import BlogCard from "../components/homepage/blog/blog-card"; -async function getData() { +async function getBlogs() { const res = await fetch(`https://dev.to/api/articles?username=${personalData.devUsername}`) if (!res.ok) { @@ -11,14 +11,11 @@ async function getData() { } const data = await res.json(); - - const filtered = data.filter((item) => item?.cover_image).sort(() => Math.random() - 0.5); - - return filtered; + return data; }; async function page() { - const blogs = await getData(); + const blogs = await getBlogs(); return (