/**
* Turns a published page's stored root props into the route's `
`
* Metadata.
*
* The mapping is the same for every P1 site — it is coupled to the shapes the
* editor stores (`root.props._seo`, `root.props._meta`), not to anything about
* a particular site's branding. Assembling it in each app froze a copy into
* every scaffold, so a change to the stored shape would silently mishandle it
* everywhere. It lives here instead, and what genuinely differs per app flows
* in as options: the datasource fetchers that back `{{ }}` templates, and a
* `transform` for the tags a site wants to add or override.
*/
import type { Metadata } from "next";
import { type RemoteDatasourceFetcher } from "@pantheon-systems/puck-css/server";
import type { Data } from "@puckeditor/core";
import { type PageMetaFields } from "./page-metadata";
/**
* Authored `_meta` as stored. The index signature is what lets a site add its
* own fields to the group: they template like the rest, and reach ``
* through `transform`.
*/
export type AuthoredPageMeta = PageMetaFields & Record;
/**
* What produced the Metadata handed to `transform` — the page it came from, and
* the authored values with any `{{ }}` already resolved. Reading the resolved
* values here is what lets a site emit a tag from a field it added, rather than
* re-resolving the templates itself.
*/
export type PageMetadataContext = {
pageData: Data | null | undefined;
path: string;
title?: string;
description?: string;
meta: AuthoredPageMeta;
};
export type ResolvePageMetadataOptions = {
pageData: Data | null | undefined;
path: string;
/** The app's remote-datasource fetcher registry, for `{{ }}` resolution. */
fetchers?: RemoteDatasourceFetcher[];
/**
* Last word on the emitted Metadata, for the tags a site wants to add or
* override. Runs after the stored values have been mapped and any templates
* resolved.
*/
transform?: (metadata: Metadata, context: PageMetadataContext) => Metadata | Promise;
};
/**
* Produces the per-page `` Metadata for a route. Title, description and
* the free-text metadata fields are template-allowed; the datasource context
* behind them is loaded once, and only when something actually carries a
* template.
*/
export declare function resolvePageMetadata({ pageData, path, fetchers, transform, }: ResolvePageMetadataOptions): Promise;