Adds a generic WebPage structured data helper
webPage(type, path, extra) builds the schema.org page data every page needs: the canonical URL as @id and url, name and description from the page registry, the language, and page-specific fields last. aboutPage now uses it and gives exactly the same output. The Portfolio and Soorten fotoshoots pages build their structured data on it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+25
-8
@@ -115,27 +115,44 @@ export function person(
|
||||
};
|
||||
}
|
||||
|
||||
// The about page with Andrea as its subject (BR-SD-06); name, description
|
||||
// and preview image come from the page registry
|
||||
export function aboutPage(
|
||||
// The schema.org page types the site uses; add one here when a page needs it
|
||||
export type WebPageType =
|
||||
'WebPage' | 'AboutPage' | 'ContactPage' | 'ImageGallery' | 'CollectionPage';
|
||||
|
||||
// Structured data for a page: its canonical URL as @id, name and description
|
||||
// from the page registry. Page-specific fields (mainEntity, about, ...) come
|
||||
// in through `extra`, which is added last and keeps its type for callers.
|
||||
export function webPage<Extra extends object = Record<never, never>>(
|
||||
type: WebPageType,
|
||||
path: RoutePath,
|
||||
content: AboutPageContent['person'],
|
||||
site: SiteContent,
|
||||
extra: Extra = {} as Extra,
|
||||
) {
|
||||
const page = sitePages[path];
|
||||
const image = siteUrl + (page.ogImage ?? defaultOgImage).path;
|
||||
return {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'AboutPage',
|
||||
'@type': type,
|
||||
'@id': canonicalUrl(path),
|
||||
url: canonicalUrl(path),
|
||||
name: page.title,
|
||||
description: page.description,
|
||||
inLanguage: 'nl-NL',
|
||||
mainEntity: person(content, site, image),
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
||||
// The about page with Andrea as its subject (BR-SD-06); her image is the
|
||||
// page's preview image from the registry
|
||||
export function aboutPage(
|
||||
path: RoutePath,
|
||||
content: AboutPageContent['person'],
|
||||
site: SiteContent,
|
||||
) {
|
||||
const image = siteUrl + (sitePages[path].ogImage ?? defaultOgImage).path;
|
||||
return webPage('AboutPage', path, {
|
||||
mainEntity: person(content, site, image),
|
||||
});
|
||||
}
|
||||
|
||||
// A head script tag with structured data, escaped by jsonLdScript (BR-SD-07)
|
||||
export function structuredDataScript(data: unknown) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user