fix: notFound() on missing post, await params for Next.js 15

This commit is contained in:
2026-03-31 02:39:33 +02:00
parent b2a611ce5b
commit 7faaac2081
2 changed files with 7 additions and 5 deletions

View File

@@ -8,9 +8,7 @@ import rehypePrettyCode from "rehype-pretty-code";
import rehypeSlug from "rehype-slug";
interface PageProps {
params: {
slug: string;
};
params: Promise<{ slug: string }>;
}
export async function generateStaticParams() {
@@ -19,14 +17,16 @@ export async function generateStaticParams() {
}
export async function generateMetadata({ params }: PageProps) {
const postData = await getPostData(params.slug);
const { slug } = await params;
const postData = await getPostData(slug);
return {
title: `${postData.title} | Gabriel's Kaszewski Blog`,
};
}
export default async function Post({ params }: PageProps) {
const postData: PostData = await getPostData(params.slug);
const { slug } = await params;
const postData: PostData = await getPostData(slug);
return (
<div className="mx-auto max-w-5xl">