Skip to content

Commit 78c0437

Browse files
committed
added blog page
1 parent 621cb2d commit 78c0437

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

app/blog/[slug]/page.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @flow strict
2+
import { personalData } from "@/utils/data/personal-data";
3+
4+
async function getBlog(slug) {
5+
const res = await fetch(`https://dev.to/api/articles/${personalData.devUsername}/${slug}`)
6+
7+
if (!res.ok) {
8+
throw new Error('Failed to fetch data')
9+
}
10+
11+
const data = await res.json();
12+
return data;
13+
};
14+
15+
async function BlogDetails({params}) {
16+
const slug = params.slug;
17+
const blog = await getBlog(slug);
18+
19+
return (
20+
<div>
21+
</div>
22+
);
23+
};
24+
25+
export default BlogDetails;

app/blog/page.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
import { personalData } from "@/utils/data/personal-data";
44
import BlogCard from "../components/homepage/blog/blog-card";
55

6-
async function getData() {
6+
async function getBlogs() {
77
const res = await fetch(`https://dev.to/api/articles?username=${personalData.devUsername}`)
88

99
if (!res.ok) {
1010
throw new Error('Failed to fetch data')
1111
}
1212

1313
const data = await res.json();
14-
15-
const filtered = data.filter((item) => item?.cover_image).sort(() => Math.random() - 0.5);
16-
17-
return filtered;
14+
return data;
1815
};
1916

2017
async function page() {
21-
const blogs = await getData();
18+
const blogs = await getBlogs();
2219

2320
return (
2421
<div className="py-8">

0 commit comments

Comments
 (0)