Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c9f0755

Browse filesBrowse files
committed
docs: update example to await async params
1 parent 13af7b5 commit c9f0755
Copy full SHA for c9f0755

File tree

1 file changed

+9
-5
lines changed
Filter options

1 file changed

+9
-5
lines changed

‎docs/01-app/01-getting-started/12-metadata-and-og-images.mdx

Copy file name to clipboardExpand all lines: docs/01-app/01-getting-started/12-metadata-and-og-images.mdx
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,19 @@ import { getPost } from '@/app/lib/data'
148148
export async function generateMetadata({
149149
params,
150150
}: {
151-
params: { slug: string }
151+
params: Promise<{ slug: string }>
152152
}) {
153-
const post = await getPost(params.slug)
153+
const slug = (await params).slug
154+
const post = await getPost(slug)
154155
return {
155156
title: post.title,
156157
description: post.description,
157158
}
158159
}
159160

160161
export default async function Page({ params }: { params: { slug: string } }) {
161-
const post = await getPost(params.slug)
162+
const slug = (await params).slug
163+
const post = await getPost(slug)
162164
return <div>{post.title}</div>
163165
}
164166
```
@@ -167,15 +169,17 @@ export default async function Page({ params }: { params: { slug: string } }) {
167169
import { getPost } from '@/app/lib/data'
168170

169171
export async function generateMetadata({ params }) {
170-
const post = await getPost(params.slug)
172+
const slug = (await params).slug
173+
const post = await getPost(slug)
171174
return {
172175
title: post.title,
173176
description: post.description,
174177
}
175178
}
176179

177180
export default async function Page({ params }) {
178-
const post = await getPost(params.slug)
181+
const slug = (await params).slug
182+
const post = await getPost(slug)
179183
return <div>{post.title}</div>
180184
}
181185
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.