fix dynamic params
Seto committed
Dec 12, 2025 at 15:41 UTC
d797c47ae3c18364088a24b15e3562fe774c6873
2 files changed
+12
-12
app/[...slug]/page.tsx
+6
-6
@@ -5,9 +5,9 @@ import { Mdx } from "@/components/mdx-components";
5
import AboutMedia from "@/components/about-media";
6
7
interface PageProps {
8
- params: {
8
+ params: Promise<{
9
slug: string[];
10
- };
10
+ }>;
11
}
12
13
async function getPageFromParams(params: PageProps["params"]) {
@@ -21,9 +21,8 @@ async function getPageFromParams(params: PageProps["params"]) {
21
return page;
22
}
23
24
-export async function generateMetadata({
25
- params,
26
-}: PageProps): Promise<Metadata> {
24
+export async function generateMetadata(props: PageProps): Promise<Metadata> {
25
+ const params = await props.params;
26
const page = await getPageFromParams(params);
27
28
if (!page) {
@@ -42,7 +41,8 @@ export async function generateStaticParams(): Promise<PageProps["params"][]> {
41
}));
42
}
43
45
-export default async function PagePage({ params }: PageProps) {
44
+export default async function PagePage(props: PageProps) {
45
+ const params = await props.params;
46
const page = await getPageFromParams(params);
47
48
if (!page) {
app/posts/[...slug]/page.tsx
+6
-6
@@ -5,9 +5,9 @@ import { Metadata } from "next";
5
import { Mdx } from "@/components/mdx-components";
6
7
interface PostProps {
8
- params: {
8
+ params: Promise<{
9
slug: string[];
10
- };
10
+ }>;
11
}
12
13
async function getPostFromParams(params: PostProps["params"]) {
@@ -23,9 +23,8 @@ async function getPostFromParams(params: PostProps["params"]) {
23
return post;
24
}
25
26
-export async function generateMetadata({
27
- params,
28
-}: PostProps): Promise<Metadata> {
26
+export async function generateMetadata(props: PostProps): Promise<Metadata> {
27
+ const params = await props.params;
28
const post = await getPostFromParams(params);
29
30
if (!post) {
@@ -45,7 +44,8 @@ export async function generateStaticParams(): Promise<PostProps["params"][]> {
44
}));
45
}
46
48
-export default async function PostPage({ params }: PostProps) {
47
+export default async function PostPage(props: PostProps) {
48
+ const params = await props.params;
49
const post = await getPostFromParams(params);
50
51
if (!post) {