Skip to content

Commit 5e448a8

Browse files
committed
feat: configure metadata
1 parent ef3ece6 commit 5e448a8

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

app/[slug]/page.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Metadata } from 'next';
12
import Link from 'next/link';
23
import { notFound } from 'next/navigation';
34
import { useMDXComponent } from 'next-contentlayer/hooks';
@@ -7,15 +8,43 @@ import { HomeIcon } from '@/components/icons';
78
import TableOfContent from '@/components/TableOfContent';
89
import { allBlogPosts, parseToc } from '@/libs/post';
910

11+
interface PostPageProps {
12+
params: {
13+
slug: string;
14+
};
15+
}
16+
1017
export 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

app/layout.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ const pretendard = localFont({
1818
});
1919

2020
export const metadata: Metadata = {
21+
title: `yuhwan park's blog`,
22+
description: `yuhwan park's blog`,
23+
robots: {
24+
index: true,
25+
follow: true,
26+
},
27+
authors: [{ name: 'yuhwan park', url: 'https://github.com/yuhwan-park' }],
28+
openGraph: {
29+
title: `yuhwan park's blog`,
30+
url: 'https://yuhwan-park.github.io/',
31+
description: `yuhwan park's blog`,
32+
},
2133
other: {
2234
['google-site-verification']: '1tOVlPGznTkcAVpMjZVMHwrVgJrkxd9IPKcfLHd0LWc',
2335
},
@@ -29,7 +41,7 @@ export default function RootLayout({
2941
children: React.ReactNode;
3042
}>) {
3143
return (
32-
<html className={`${nanum.variable} ${pretendard.variable}`}>
44+
<html lang="ko" className={`${nanum.variable} ${pretendard.variable}`}>
3345
<body>{children}</body>
3446
</html>
3547
);

0 commit comments

Comments
 (0)