mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Adds support for using `"use cache"` in the special metadata route handlers like [`sitemap.ts`](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generating-a-sitemap-using-code-js-ts), [`opengraph-image.tsx`](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#generate-images-using-code-js-ts-tsx), [`icon.tsx`](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/app-icons#generate-icons-using-code-js-ts-tsx), and other [metadata files](https://nextjs.org/docs/app/api-reference/file-conventions/metadata). reverts #71225 fixes #74146 closes NAR-51 As a follow-up we need to ensure that opengraph image responses do not bail out of static generation when `dynamicIO` is enabled.
13 lines
338 B
TypeScript
13 lines
338 B
TypeScript
import type { MetadataRoute } from 'next'
|
|
import { getSentinelValue } from './sentinel'
|
|
import { setTimeout } from 'timers/promises'
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
'use cache'
|
|
|
|
// Simulate I/O
|
|
await setTimeout(100)
|
|
|
|
return [{ url: `https://acme.com?sentinel=${getSentinelValue()}` }]
|
|
}
|