Skip to content

Commit 4e7b603

Browse files
committed
Update page.tsx
1 parent 84f0fdb commit 4e7b603

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

app/blog/[slug]/page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPostBySlug } from "@/lib/blog"
1+
import { getPostBySlug, getSortedPosts } from "@/lib/blog"
22
import { format } from "date-fns"
33
import { notFound } from "next/navigation"
44
import Image from "next/image"
@@ -8,15 +8,15 @@ import { Button } from "@/components/ui/button"
88
import Markdown from "react-markdown"
99
import rehypeHighlight from "rehype-highlight"
1010

11-
type BlogPostPageProps = {
12-
params: {
13-
slug: string
14-
}
15-
searchParams?: { [key: string]: string | string[] | undefined }
11+
export async function generateStaticParams() {
12+
const posts = await getSortedPosts()
13+
return posts.map((post) => ({
14+
slug: post.slug,
15+
}))
1616
}
1717

18-
export default async function BlogPostPage({ params }: BlogPostPageProps) {
19-
const post = await getPostBySlug(params.slug)
18+
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
19+
const post = await getPostBySlug((await params).slug)
2020

2121
if (!post) {
2222
notFound()

0 commit comments

Comments
 (0)