1+ import { Metadata } from 'next' ;
12import Link from 'next/link' ;
23import { notFound } from 'next/navigation' ;
34import { useMDXComponent } from 'next-contentlayer/hooks' ;
@@ -7,15 +8,43 @@ import { HomeIcon } from '@/components/icons';
78import TableOfContent from '@/components/TableOfContent' ;
89import { allBlogPosts , parseToc } from '@/libs/post' ;
910
11+ interface PostPageProps {
12+ params : {
13+ slug : string ;
14+ } ;
15+ }
16+
1017export async function generateStaticParams ( ) {
1118 return allBlogPosts . map ( ( post ) => ( {
1219 slug : post . slug . slice ( 1 ) ,
1320 } ) ) ;
1421}
1522
16- interface PostPageProps {
17- params : {
18- slug : string ;
23+ export async function generateMetadata ( { params } : PostPageProps ) : Promise < Metadata > {
24+ const post = allBlogPosts . find ( ( post ) => post . slug === `/${ params . slug } ` ) ;
25+
26+ if ( ! post ) return { } ;
27+
28+ return {
29+ title : `${ post . title } | yuhwan park's blog` ,
30+ description : post . title ,
31+ alternates : {
32+ canonical : `https://yuhwan-park.github.io${ post . slug } ` ,
33+ } ,
34+ robots : {
35+ index : true ,
36+ follow : true ,
37+ } ,
38+ authors : [ { name : 'yuhwan park' , url : 'https://github.com/yuhwan-park' } ] ,
39+ openGraph : {
40+ type : 'article' ,
41+ publishedTime : new Date ( post . date ) . toISOString ( ) ,
42+ modifiedTime : new Date ( post . date ) . toISOString ( ) ,
43+ authors : [ 'yuhwan park' ] ,
44+ title : `yuhwan park's blog` ,
45+ url : `https://yuhwan-park.github.io${ post . slug } ` ,
46+ description : post . title ,
47+ } ,
1948 } ;
2049}
2150
0 commit comments