Skip to main content

Function: artifactMetadata()

artifactMetadata(artifact): Metadata

Defined in: artifactMetadata.ts:41

Turns a resolved artifact into the Metadata Next emits into the document head, so the title and meta tags a page carries come from the document that was published rather than from the code serving it.

Parameters​

artifact​

Artifact | null

What resolveArtifact answered with. null is the unpublished case and belongs here, so a caller resolves once and hands the same value to the page and to generateMetadata.

Returns​

Metadata

title always, description and robots when the document carried them, and canonical moved under alternates, which is where Next reads one. A field the document omitted is omitted here rather than set to undefined. A null artifact answers {}, leaving the layout's own metadata standing for the 404 the page is about to render.

Example​

export async function generateMetadata({
params,
}: { params: Promise<{ slug?: string[] }> }): Promise<Metadata> {
const { slug } = await params;
return artifactMetadata(await resolveArtifact(store, slug));
}