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>
2.3 KiB
2.3 KiB
Code Summary — Unit 1: webPage helper
Changed files
web/src/seo.ts— newWebPageTypeandwebPage();aboutPage()rebuilt onwebPage()web/src/seo.test.ts— newdescribe('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;
extrais spread last; its fields keep their types for the caller (e.g.page.mainEntity.imagestays typed).aboutPage(path, content, site)keeps its signature; it is nowwebPage('AboutPage', path, { mainEntity: person(...) }).- Adding a page type: one line in the
WebPageTypeunion.
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.