# CMS integration The site talks to the SLP CMS host through its API. On the test host the CMS host serves the site itself, so every call is same-origin (`/api/v1/*`, CSP `connect-src 'self'`, no CORS). Three things come from the CMS: the shoot packages, two banners and the contact form. ## Shoot packages Source: `GET /api/v1/offerings`. One list feeds the price cards on the home page and on the pages for each shoot type, the "welke shoot" choices of the contact form and the `?pakket=` check, so they can never disagree. - **Any number of packages.** The cards are a wrapping flex row. On desktop (`lg` and up) every card is a third of the row (`calc((100% - 2 * gap) / 3)`) and every row is centred, so an incomplete last row (4, 5, 7, 8, 10 cards, ...) sits in the middle. There is no styling per number of cards. On phone and tablet the cards are one column; there is no swipe row. - **Mapping** (`web/src/lib/offerings.ts`, pure functions): `slug` is the package id (kept `zwangerschap`, `newborn`, `gezin`: they appear in `?pakket=` and the form), `title` the name, the free price text is read as whole euros ("€ 175", "€ 1.250", "175,-"). A card with an unreadable price, no features or a bad slug is skipped. Order follows `displayOrder`. Empty `description`, `priceNote` and `ctaLabel` are accepted and left out of the card. - **Where the data comes from, in order:** 1. At build time `web/config/fetchOfferings.ts` (the first step of `pnpm build`) asks `OFFERINGS_URL` (10 s timeout, 2 attempts) and writes the gitignored `web/src/content/offerings.generated.json`. The packages are baked into the prerendered HTML (search engines see the prices, no layout jump). 2. Without `OFFERINGS_URL`, with a CMS that is down or with an unusable answer, the committed `web/src/content/offerings.snapshot.json` is used. The build never fails and never shows empty prices; the log says which source was used. Tests always use the snapshot. 3. After hydration `PackagesProvider` (`web/src/components/PackagesProvider/`) asks the CMS once and replaces the baked list only if the answer differs. A network error, time-out (8 s), bad status or invalid answer keeps what was baked. A change in the CMS therefore shows at once; the nightly build only matters for search engines. - **Featured package** (the star in the CMS admin, field `featured`): the card gets a heidegroen rule along its top, a heidegroen border and a small "Uitgelicht" tab on the top edge (`PriceCard`). The tab is positioned on the border, so the cards of a row keep the same layout. Any number of cards may be featured. - **Description, price note and button label** (`description`, `priceNote`, `ctaLabel`) are optional in the CMS and the site does not use them: they are not shown and a card never depends on them (empty, `null` or absent all give the same card; covered by tests). - **Scheduling in the CMS:** the API only returns packages that are live at the moment of the request (switched on and inside their from/to dates), so the site shows them and nothing else. The baked list reflects the moment of the build; the live refresh after hydration corrects it for every visitor, and the nightly build corrects it for search engines. A package that goes live or expires between two builds is therefore right in the browser but can be stale in the HTML until the next build. - **Keep the snapshot current** when the real packages change (prices, features), because production builds use it (see "Hosting" below). ## Banners (OfferingBanner) Source: `GET /api/v1/offerings/banner?position=top|bottom`. No parameter means `bottom`; `204` means no active banner; an invalid value is `400`. Answer fields: `title` (at most 100 characters), `text` (at most 300 for bottom, 120 for top), `linkLabel`, `linkUrl` (both or neither; `https://` or a path on the site with one `/`) and `position`. Both banners may be active and visible at the same time. | | Under the cards (`bottom`) | Above the cards (`top`) | | --------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | | Component | `PriceBanner` | `PriceTopBar` | | Look | Light band, thin heidegroen top rule, section-heading title, ornament, deep-green link button | Slim white bar, same hairline and top rule, one line: small capitals title, diamond, text, small underlined link | | Required | title | title or text (title may be empty) | | Mapping | `mapBanner` | `mapTopBanner` | Both follow the same rules as the packages: baked into the HTML at build time, replaced live after hydration, empty fields are hidden, an error or invalid answer keeps what was baked. A `204` hides that banner (the one deliberate exception to "keep what was baked"); the two banners are independent of each other. Neither banner is a package: not in the form choices, not in the package count. **Layout shift:** a banner that was not active at the last build is not in the HTML. When it appears live, the content below it moves down by its height once (for the top bar, the cards move). Rebuilding with the banner active (the nightly test build does this) removes the shift. The same holds in reverse when a baked banner is switched off. ## Contact form `GET /api/v1/contact-messages/token` and `POST /api/v1/contact-messages` through the headless `web/src/cms-client`. The form is behind the switch `contactForm.enabled` in `web/src/content/siteContent.ts` (off means the "Binnenkort" gate and no request to the server). Details and the go-live conditions are in `aidlc-docs/features/contact-form-cms/` and [go-live-checklist.md](go-live-checklist.md). Friendly Captcha is off at go-live. ## Hosting: the CMS host serves everything Decision (Bryan, 2026-11-15): the hosting package has one entry per website. The CMS host (Kestrel) is that entry and serves the website itself (the prerendered pages), `/admin` and `/api/v1/*`. In production IIS (or the proxy) therefore passes **all** requests to the CMS host, not only `/api/v1/*`, and serves no static files or HTML cache of its own. This holds for the test host and for ASF production alike. - **Test (ASF):** nginx on the proxy Pi forwards everything for `test.andreaslop.nl` to the CMS host (`web/deploy/nginx/test.andreaslop.nl.proxy.conf`), which serves the site files and the API. Nothing to add. - **Production: not in place yet.** The generated `web/deploy/iis/web.config` and the FTP upload of static files (`web/deploy/upload-production.sh`) still describe the old idea of IIS serving the files. They have to change with the production hosting: IIS keeps only the redirects (www, HTTPS) and the pass-through to the CMS host, and the prerendered `dist/` goes to the CMS host's prerendered-pages folder as on test. Security headers then come from the CMS host (as on test). This is part of the production hosting work, not of the packages feature. Until then production builds use the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows a 404 for the API). Change generated server files only in `web/config/serverConfig.ts` and run `pnpm server-config`. - **Host injection (built in the site; the host side is the CMS repo's work):** the build leaves markers in the prerendered pages and the CMS host fills them from live data, so a CMS change is visible to search engines at once without a rebuild. Contract and plan: `aidlc-docs/features/asf-cms-host-injection/plan.md`; golden files for the list HTML: `web/contract/host-injection/`. - Markers: `` + `