Hero from the CMS: markers HERO-HTML and HERO-PRELOAD, hero key in the data block, picture per ratio, baked fallback
The prerendered hero is plain HTML between the markers (first photo, h1, buttons), the slider takes over after hydration with the hero of the host block, the API or the build. The head preload is added to the finished HTML. Hero texts move into nl.json. The stand-in host and the e2e tests cover the hero. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,16 @@ Both follow the same rules as the packages: baked into the HTML at build time, r
|
||||
|
||||
**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.
|
||||
|
||||
## Hero (CMS module)
|
||||
|
||||
The hero of the homepage comes from the CMS hero module (`GET /api/v1/hero`); the build bakes one in as the fallback (`web/src/content/heroContent.ts`, texts in `nl.json` under `hero.baked`).
|
||||
|
||||
- **Markers.** `index.html` has `<!--CMS:HERO-HTML-->…<!--/CMS:HERO-HTML-->` (first photo as `<picture>`, the `h1` with tagline and title, the buttons) and, in the head, `<!--CMS:HERO-PRELOAD-->…<!--/CMS:HERO-PRELOAD-->` (the preload links). The head markers are added to the finished HTML by `config/heroPreload.ts` (React cannot write a comment into the head), as part of `config/externalizeInlineScripts.ts`. The host rewrites both from live data; the contract is `web/contract/host-injection/hero/` (README, seed, golden files shared with the CMS repo). Code: `src/lib/hero.ts` (mapping), `src/lib/heroHtml.ts` (HTML and preload).
|
||||
- **Data block.** `#cms-data` gets a `hero` key (the answer of `/api/v1/hero`). After hydration `src/components/Hero/useHero.ts` takes it; without a host block the site asks `/api/v1/hero` itself (8 s time-out). A missing block, a 204, an error or an answer without a usable slide keeps the baked hero (fail open).
|
||||
- **Until hydration** the hero is the plain HTML between the markers, styled by the global CSS `.cms-hero-*` in `src/theme.ts`; the slider (arrows, pause, progress) only exists after hydration, so a visitor without JavaScript sees the first photo and no dead controls. Slides after the first also get AVIF `<source>`s; the first and the preload are WebP only.
|
||||
- **Images.** Ratios `wide` (3:2) and `tall` (4:5; portrait screens), chosen by `(orientation: portrait)`; the focus point is `object-position`. Alt texts and the slider's aria texts are in `nl.json` (`hero`); a decorative photo has `alt=""`.
|
||||
- **Stand-in host.** `config/hostInjector.ts` (preview server and e2e) writes the hero regions and the `hero` key like the real host; `e2e/hostInjection.e2e.ts` covers it.
|
||||
|
||||
## 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.
|
||||
|
||||
Reference in New Issue
Block a user