mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Follow-up to https://github.com/vercel/next.js/pull/65825 this ensures we don't skip the static optimization specifically for metadata routes as this most often should be static as they aren't dynamic content and are requested very frequently.
39 lines
805 B
TypeScript
39 lines
805 B
TypeScript
import { ImageResponse } from 'next/og'
|
|
|
|
// Image metadata
|
|
export const alt = 'About Acme'
|
|
export const size = {
|
|
width: 1200,
|
|
height: 630,
|
|
}
|
|
|
|
export const contentType = 'image/png'
|
|
|
|
// Image generation
|
|
export default async function Image() {
|
|
return new ImageResponse(
|
|
(
|
|
// ImageResponse JSX element
|
|
<div
|
|
style={{
|
|
fontSize: 128,
|
|
background: 'white',
|
|
width: '100%',
|
|
height: '100%',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
}}
|
|
>
|
|
About Acme
|
|
</div>
|
|
),
|
|
// ImageResponse options
|
|
{
|
|
// For convenience, we can re-use the exported opengraph-image
|
|
// size config to also set the ImageResponse's width and height.
|
|
...size,
|
|
}
|
|
)
|
|
}
|