Builds the markers, data block and stand-in host for the CMS host injection

The pages carry the CMS markers (data block, list regions, JSON-LD price,
inline price); PackagesProvider reads the host's data block after hydration
and asks the API only when there is none; the site address comes from the
block. A stand-in for the host (config/hostInjector.ts, --cms-data in the
preview server) and browser tests check the behaviour with different data.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 16:21:08 +01:00
co-authored by Claude Sonnet 5.5
parent 16027f5688
commit bf21b6f690
26 changed files with 1207 additions and 70 deletions
@@ -64,7 +64,7 @@ Why not exact copies of the styled cards: Chakra/Emotion class names and styles
The host (CMS repo) finds all markers in one pass. A page with no marker and without the written production address is served unchanged as a static file. **Fail open everywhere:** a missing marker does nothing, invalid or missing data leaves the baked page as it is, an unknown slug keeps the baked fallback.
1. **List regions** `<!--CMS:OFFERINGS-HTML-->…<!--/CMS:OFFERINGS-HTML-->`, and for the banners `<!--CMS:BANNER-TOP-HTML-->…<!--/CMS:BANNER-TOP-HTML-->` and `<!--CMS:BANNER-BOTTOM-HTML-->…<!--/CMS:BANNER-BOTTOM-HTML-->`: the host replaces the content between the markers by simple crawlable HTML from the live data (C# template, everything HTML-encoded); the markers stay. No live data or a provider error keeps the baked fallback. Spec and golden files below.
2. **Data** `<!--CMS:DATA-->` directly followed by the baked `<script type="application/json" id="cms-data">…</script>`: the host replaces the pair by the live block `{"siteUrl":"…","offerings":[…],"banners":{"top":…|null,"bottom":…|null}}` (offerings and banners exactly as the public GETs; `<`, `>`, `&`, U+2028 and U+2029 written as `\uXXXX` escapes). Without a block after the marker the live block replaces the marker. `siteUrl` is the effective public base URL (see 5), which the client needs because the JS bundle cannot be rewritten (immutable assets).
2. **Data** `<!--CMS:DATA-->` directly followed by the baked `<script type="application/json" id="cms-data">…</script>`: the host replaces the pair by the live block `{"siteUrl":"…","offerings":[…],"banners":{"top":…|null,"bottom":…|null}}` (offerings and banners exactly as the public GETs; `<`, `>`, `&`, U+2028 and U+2029 written as `\uXXXX` escapes). Without a block after the marker the live block replaces the marker. The block the build bakes carries `"source":"build"` (the host replaces the whole block, so the live one has no `source`); the site treats a block with that source as "no host data" and asks the API itself, as before the injection existed. `siteUrl` is the effective public base URL (see 5), which the client needs because the JS bundle cannot be rewritten (immutable assets).
3. **JSON-LD price** `<!--CMS:OFFER-JSON-LD slug="newborn"-->` directly before `<script type="application/ld+json">…</script>`: the host parses the block and sets `offers.price` (whole euros, our parsing: "€ 175", "€ 1.250", "175,-") on the node that has `offers`; when the package is gone, switched off, scheduled or has no readable price, `offers` is removed from that node. A database or provider failure is different: the baked block stays (fail open). A block that is not valid JSON stays. The marker comment is removed; property order is kept. Only the shoot pages of newborn, zwangerschap and gezin get this marker; loveshoot, portret ("Prijs op aanvraag"), the overview and the home page get none.
4. **Inline value** `<span data-cms-price="newborn">€ 185</span>`: the host replaces the text by "€" + U+00A0 + whole euros; an unknown slug or an unreadable price leaves the span alone. Only simple, non-nested spans with exactly this attribute. Used in the price block of a shoot page.
5. **Own address** (`Website:AuthoredBaseUrl`): the same injector replaces the written production address in every HTML page, `sitemap.xml` and `robots.txt` by `Website:PublicBaseUrl` when that is set on the host (test: `https://test.andreaslop.nl`; production: equal or empty, nothing to replace). One artifact then serves test and production, and `VITE_SITE_URL` no longer differs per environment. The ASF build is written with `https://andreaslop.nl` (the non-www canonical origin; IIS redirects www to it). The site has no web manifest. The client takes its address from `siteUrl` in the data block (fallback: the production address), not from the bundle, so canonical and `og:` tags stay right after hydration and on navigation.