# 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 ```ts export type WebPageType = | 'WebPage' | 'AboutPage' | 'ContactPage' | 'ImageGallery' | 'CollectionPage'; export function webPage>( 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 ```ts 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.