Files
AndreaSlopFotografie/aidlc-docs/features/contact-page/construction/webpage-helper/code/code-summary.md
T
SluijsensandClaude Opus 5.5 4c257b7ac0 Plans the Contact page and records unit 1 as generated
Workspace detection, a reverse engineering delta, requirements with the
approved layout mockups, the execution plan and the application design
for the Contact page, plus the code generation plan and summary of the
webPage helper. Corrects the contact payload in the shared API notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 16:59:38 +01:00

2.3 KiB

Code Summary — Unit 1: webPage helper

Changed files

  • web/src/seo.ts — new WebPageType and webPage(); aboutPage() rebuilt on webPage()
  • web/src/seo.test.ts — new describe('webPage') with example and property tests

No other files; the commit can be cherry-picked on its own by portfolio-page and soorten-fotoshoots-page.

Interface

export type WebPageType =
    | 'WebPage'
    | 'AboutPage'
    | 'ContactPage'
    | 'ImageGallery'
    | 'CollectionPage';

export function webPage<Extra extends object = Record<never, never>>(
    type: WebPageType,
    path: RoutePath,
    extra?: Extra,
): {
    '@context': 'https://schema.org';
    '@type': WebPageType;
    '@id': string;      // canonicalUrl(path)
    url: string;        // canonicalUrl(path)
    name: string;       // sitePages[path].title
    description: string; // sitePages[path].description
    inLanguage: 'nl-NL';
} & Extra;
  • extra is spread last; its fields keep their types for the caller (e.g. page.mainEntity.image stays typed).
  • aboutPage(path, content, site) keeps its signature; it is now webPage('AboutPage', path, { mainEntity: person(...) }).
  • Adding a page type: one line in the WebPageType union.

Usage for the other pages

webPage('ContactPage', '/contact', { about: { '@id': businessId } });
webPage('ImageGallery', '/portfolio', { /* ... */ });
webPage('WebPage', '/soorten-fotoshoots', { mainEntity: { '@type': 'ItemList', /* ... */ } });

Wrap the result with structuredDataScript() in the route's head().

Tests

Test Kind Property
describes a page from the registry example full ContactPage output
needs no extra fields example default extra
takes name, description and URL from the registry PBT invariant @id = url = canonical; @type, name, description, language
keeps every extra field as given PBT invariant arbitrary JSON extras present unchanged
survives the ld+json script unchanged PBT round trip JSON.parse(jsonLdScript(page)) equals the page
leaves the about page data exactly as it was PBT oracle new aboutPage() equals the previous implementation for generated site content, paths and specialisations

Existing aboutPage tests unchanged and passing.