File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import BlogDeatails from "@/components/blog/details" ;
2+ import { blogData } from "@/static/blog" ;
3+ export async function generateStaticParams ( ) {
4+ return blogData . map ( ( post ) => ( {
5+ slug : post . id ,
6+ } ) ) ;
7+ }
8+
9+ export default function Page ( {
10+ params : { slug } ,
11+ } : {
12+ params : { slug : string } ;
13+ } ) {
14+ return < BlogDeatails id = { slug } /> ;
15+ }
Original file line number Diff line number Diff line change 11"use client" ;
22
3- import React , { useEffect , useState } from "react" ;
4- import { useParams } from "next/navigation" ;
53import { blogData } from "@/static/blog" ;
64import { BlogItem } from "@/types/blog" ;
7- import DetailHero from "./DetailHero " ;
5+ import { useEffect , useState } from "react " ;
86import DetailContent from "./DetailContent" ;
7+ import DetailHero from "./DetailHero" ;
98
10- const BlogDeatails = ( ) => {
11- const params = useParams ( ) ; // get id from URL
9+ const BlogDetails = ( { id } : { id : string } ) => {
1210 const [ post , setPost ] = useState < BlogItem | null > ( null ) ;
1311
1412 useEffect ( ( ) => {
15- if ( params ?. id ) {
16- const found = blogData . find ( ( b ) => b . id . toString ( ) === params . id ) ;
13+ if ( id ) {
14+ const found = blogData . find ( ( b ) => b . id . toString ( ) === id ) ;
1715 setPost ( found || null ) ;
1816 }
19- } , [ params ?. id ] ) ;
17+ } , [ id ] ) ;
2018
2119 if ( ! post ) return < div > Loading or blog not found...</ div > ;
2220
@@ -30,9 +28,10 @@ const BlogDeatails = () => {
3028 date = { post . author . date }
3129 readTime = { post . author . readTime }
3230 />
31+
3332 < DetailContent content = { post . content } />
3433 </ div >
3534 ) ;
3635} ;
3736
38- export default BlogDeatails ;
37+ export default BlogDetails ;
You can’t perform that action at this time.
0 commit comments