Skip to content

Commit fb4953e

Browse files
authored
fix metadata api interface (#18)
1 parent 61d5862 commit fb4953e

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/mcp-prompts/nextjs-16-critical-rules.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ export async function generateImageMetadata({ params }) {
5858
}
5959

6060
// ✅ AFTER (Next.js 16)
61-
export default async function Image(props, id) {
62-
const params = await props.params // params now async
63-
const imageId = await id // id is now Promise<string> when using generateImageMetadata
64-
const slug = params.slug
61+
export default async function Image({ params, id }) {
62+
const resolvedParams = await params // params is now a Promise
63+
const slug = resolvedParams.slug
64+
const imageId = id // string (id itself is not a Promise)
6565
// ...
6666
}
6767

68-
export async function generateImageMetadata(props) {
69-
const params = await props.params
68+
export async function generateImageMetadata({ params }) {
69+
const resolvedParams = await params // params is now a Promise
7070
return [{ id: '1' }, { id: '2' }]
7171
}
7272
```
@@ -279,8 +279,8 @@ export default async function Page(props) {
279279
- [ ] `function Layout({ params })``async function Layout(props)` + `await props.params`
280280
- [ ] `generateMetadata({ params })``async generateMetadata(props)` + `await props.params`
281281
- [ ] `generateViewport({ params })``async generateViewport(props)` + `await props.params`
282-
- [ ] Metadata image routes: `function Image({ params, id })``async function Image(props, id)` + `await props.params` + `await id`
283-
- [ ] `generateImageMetadata({ params })``async generateImageMetadata(props)` + `await props.params`
282+
- [ ] Metadata image routes: `function Image({ params, id })``async function Image({ params, id })` + `await params`
283+
- [ ] `generateImageMetadata({ params })``async generateImageMetadata({ params })` + `await params`
284284
- [ ] `cookies().get()``(await cookies()).get()`
285285
- [ ] `headers().get()``(await headers()).get()`
286286
- [ ] `draftMode().isEnabled``(await draftMode()).isEnabled`

src/mcp-prompts/upgrade-nextjs-16-prompt.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ After the codemod runs, check for any remaining issues it might have missed:
268268

269269
**METADATA IMAGE ROUTES - Important Changes:**
270270
For metadata image route files (opengraph-image, twitter-image, icon, apple-icon):
271-
- The first argument changes from `{ params }` to `params` (aligned with other App Router routes)
272-
- `params` is now async: `await props.params`
273-
- The second argument `id` becomes `Promise<string>` when using `generateImageMetadata`
271+
- The function signature remains `{ params, id }` but `params` becomes a Promise
272+
- `params` is now async: `await params`
273+
- The `id` parameter remains a string (not a Promise)
274274

275275
```typescript
276276
// ❌ BEFORE
@@ -279,9 +279,10 @@ After the codemod runs, check for any remaining issues it might have missed:
279279
}
280280

281281
// ✅ AFTER
282-
export default async function Image(props, id) {
283-
const params = await props.params
284-
const imageId = await id // if using generateImageMetadata
282+
export default async function Image({ params, id }) {
283+
const resolvedParams = await params // params is now a Promise
284+
const slug = resolvedParams.slug
285+
const imageId = id // string
285286
}
286287
```
287288

0 commit comments

Comments
 (0)