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:
@@ -42,7 +42,10 @@ Decision (Bryan, 2026-11-15): the hosting package has one entry per website. The
|
||||
|
||||
- **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`.
|
||||
- **Next step (planned, separate feature after the current merges):** the CMS host injects the current packages, banners and later gallery and hero into the prerendered pages through markers, so a CMS change is visible to search engines at once and no rebuild is needed for it. The plan is in `aidlc-docs/features/asf-cms-host-injection/plan.md`; nothing of it is built yet. The browser-side live refresh described above stays as the safety net until then.
|
||||
- **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: `<!--CMS:DATA-->` + `<script type="application/json" id="cms-data">` (root document, every page), `<!--CMS:OFFERINGS-HTML-->`, `<!--CMS:BANNER-TOP-HTML-->` and `<!--CMS:BANNER-BOTTOM-HTML-->` regions (home page), `<!--CMS:OFFER-JSON-LD slug="...">` before the ld+json block of the newborn, zwangerschap and gezin pages, and `<span data-cms-price="slug">` in their price block.
|
||||
- In the page: `CmsRegion` renders the plain HTML between the markers (`lib/cmsHtml.ts`, styled by `.cms-*` rules in `theme.ts`) and React leaves it alone until hydration, so a host that wrote different data causes no hydration mismatch; after hydration the styled components take over. `PackagesProvider` reads the data block in the first render after hydration (`hostCmsData`); a block with `"source":"build"` is the baked one and counts as "no host data", so the page asks the API as before. The site address comes from `siteUrl` in the block (`setSiteUrl` in `client.tsx`), because the script files cannot be rewritten per host.
|
||||
- Tests: golden files (`src/lib/cmsHtml.test.ts`), a stand-in for the host (`config/hostInjector.ts`, also in the preview server as `--cms-data=<json>`) and browser tests with it (`e2e/hostInjection.e2e.ts`: HTML without JavaScript, hydration without errors, banners hidden on 204, JSON-LD price edited or removed, address changed and kept after navigation, unusable data, hostile text).
|
||||
|
||||
## Environment and variables
|
||||
|
||||
|
||||
Reference in New Issue
Block a user