File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change 3
3
import { personalData } from "@/utils/data/personal-data" ;
4
4
import BlogCard from "../components/homepage/blog/blog-card" ;
5
5
6
- async function getData ( ) {
6
+ async function getBlogs ( ) {
7
7
const res = await fetch ( `https://dev.to/api/articles?username=${ personalData . devUsername } ` )
8
8
9
9
if ( ! res . ok ) {
10
10
throw new Error ( 'Failed to fetch data' )
11
11
}
12
12
13
13
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 ;
18
15
} ;
19
16
20
17
async function page ( ) {
21
- const blogs = await getData ( ) ;
18
+ const blogs = await getBlogs ( ) ;
22
19
23
20
return (
24
21
< div className = "py-8" >
You can’t perform that action at this time.
0 commit comments