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.
15 lines
345 B
TypeScript
15 lines
345 B
TypeScript
import type { MetadataRoute } from 'next'
|
|
import { getSentinelValue } from './sentinel'
|
|
import { setTimeout } from 'timers/promises'
|
|
|
|
export default async function robots(): Promise<MetadataRoute.Robots> {
|
|
'use cache'
|
|
|
|
// Simulate I/O
|
|
await setTimeout(100)
|
|
|
|
return {
|
|
rules: { userAgent: '*', allow: `/${getSentinelValue()}` },
|
|
}
|
|
}
|