Files
Jiachi LiuandGitHub 5883a9a3a4 Fix sitemap generateSitemaps support for string id (#61088)
### What

Fixes the string id that broken when sitemap is optimized to static
route.

### Why

When sitemap is optimized to static route in production, the route
argument is changed from `[[...__metadata_id__]]` to
`[__metadata_id__]`, so the type of it is also changed from array to
string that should reflect in the loader code.

Fixes #60894 
Closes NEXT-2154
2024-01-24 16:52:52 +01:00

24 lines
465 B
TypeScript

import { MetadataRoute } from 'next'
export async function generateSitemaps() {
return [
{ id: 'child0' },
{ id: 'child1' },
{ id: 'child2' },
{ id: 'child3' },
]
}
export default function sitemap({ id }): MetadataRoute.Sitemap {
return [
{
url: `https://example.com/dynamic/${id}`,
lastModified: '2021-01-01',
},
{
url: `https://example.com/dynamic/${id}/about`,
lastModified: '2021-01-01',
},
]
}