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.
|
||||
|
||||
@@ -4,12 +4,12 @@ The texts of the site live in language files, not in the components. Dutch is th
|
||||
|
||||
## Where things are
|
||||
|
||||
- `web/src/i18n/nl.json`: all Dutch texts of the site in one file, in blocks per area in the order of the site: `common`, `site`, `home`, `about`, `contact`, `shoots`, `portfolio`, `instagram`, `testimonials`, `seo`, `cmsClient`. The file is the source of the types. A second language is `web/src/i18n/en.json` with the same keys.
|
||||
- `web/src/i18n/nl.json`: all Dutch texts of the site in one file, in blocks per area in the order of the site: `common`, `site`, `hero`, `home`, `about`, `contact`, `shoots`, `portfolio`, `instagram`, `testimonials`, `seo`, `cmsClient`. The file is the source of the types. A second language is `web/src/i18n/en.json` with the same keys.
|
||||
- `web/src/i18n/index.ts`: `t(key, params?)` for a text, `tList(key)` for a list of texts, `tPlural(key, count, params?)` for a text with a singular and a plural form, `locales`, `locale` and `Messages`.
|
||||
- `web/src/i18n/compare.ts`: the checks the tests use (same keys and parameters, nothing empty).
|
||||
- The typed content modules in `web/src/content` keep their structure, images and paths; the words come from the language files.
|
||||
|
||||
Not in the language files: the hero (becomes a CMS module), the privacy statement (separate feature), and everything that comes from the CMS (packages, banners, later the gallery).
|
||||
Not in the language files: the privacy statement (separate feature), and everything that comes from the CMS (packages, banners, later the gallery).
|
||||
|
||||
## Keys
|
||||
|
||||
@@ -42,7 +42,7 @@ Dotted paths: the block (`common`, `home`, ...), then the page or section, then
|
||||
|
||||
The block `cmsClient` holds the texts of the shared `src/cms-client` package, per part of the package: `cmsClient.contact` has the form's field errors, fallback, waiting time (`rateLimited.one/other` with `{minutes}`), too-large, captcha-required, failure (`{address}`) and the sending label. `src/i18n/cmsClientMessages.ts` builds the `ContactMessages` object from it and `ContactForm` passes it to `useContactForm({ messages })`. The package keeps its own Dutch defaults (`messages.nl.ts`) as a fallback and a test checks that both say the same. Parts that come later (offerings) get their own part of the block.
|
||||
|
||||
Not here: the hero, the privacy statement and everything from the CMS.
|
||||
Not here: the privacy statement and everything from the CMS.
|
||||
|
||||
## Importing the language files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user