Hero uit het CMS met ingebakken terugval: markers CMS:HERO-HTML, CMS:HERO-PRELOAD en CMS:DATA, hero-teksten naar nl.json, lint ook op Hero, tests en docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 16:48:56 +01:00
co-authored by Claude Sonnet 5.5
parent 72dd381cf9
commit 27c5ecb80f
16 changed files with 400 additions and 62 deletions
+36
View File
@@ -0,0 +1,36 @@
# Hero from the CMS (SLP Software site)
The title, lead and buttons of the hero come from the CMS. The baked hero stays as the fallback. Contract and CMS side: the CMS repository, `aidlc-docs/features/hero-module/inception/requirements/site-contract-agreed-with-asf.md` and `docs/hero-module.md`.
## What is CMS content and what is fixed
| Part | Source |
|---|---|
| Title (one field, a new line is a line break) | CMS, key `hero.title` |
| Lead | CMS, `hero.lead` (no lead: no paragraph) |
| Two buttons (label + target) | CMS, `hero.buttons` (none: no buttons) |
| Tagline, slides, display | Not used by this site (ignored) |
| Small line "Web & .NET development", code line, prompt | Fixed text, `src/i18n/nl.json`, block `home.hero` |
| Screen-reader and search-engine `h1` | Derived: `home.hero.headingPrefix` ("SLP Software:") + a space + the title lines joined with single spaces |
| Baked fallback (title lines, lead, buttons, heading) | `src/i18n/nl.json`, `home.hero.fallback`, via `heroContent` in `src/features/landing/data/content.ts` |
Seed (`hero-sls.json`): title "Websites,\napps\n& meer." gives the heading "SLP Software: Websites, apps & meer." The baked heading stays "SLP software: websites, apps & meer" (unchanged, so the prerender is unchanged); the two differ only in capitals and the final full stop.
## How it works
1. `index.html` has `<!--CMS:HERO-PRELOAD--><!--/CMS:HERO-PRELOAD-->` and `<!--CMS:DATA-->` followed by a baked `<script type="application/json" id="cms-data">{}</script>`. The build (`scripts/prerender.mjs`) writes `<!--CMS:HERO-HTML-->` ... `<!--/CMS:HERO-HTML-->` around the baked title, lead and buttons in the prerendered `#root` (the code strip is outside the region). The host replaces the regions and the data block per request (60 s cache); nothing else about the page changes. Without a host, or when the host answers 204, the markers are plain comments.
2. At start-up the app reads `#cms-data` once (`src/cms-client/hero`, `useCmsHero`), synchronously in the first render, so there is no flash of baked text. `parseHero` checks everything: no usable title, invalid JSON or no `hero` key gives the baked hero. Buttons with an empty label or a target that is not `#anchor`, `/path` or `https://...` are skipped (`isSafeTarget`), at most two are used.
3. `Hero.tsx` (design B) and `Era2026.tsx` (time travel 2026) render the same content: the first button solid, the second outline.
4. A change in the CMS is visible on the next page load (host cache 60 s, direct invalidation in the host).
## Without a CMS hero (fallback)
No data block, `hero: null` (204: no hero, not live, outside the schedule), or invalid data: the baked hero. The prerender always uses the baked hero.
## Baseline
The only change in the prerendered text compared with the build before this feature is the extra marker comments and the empty data block (`pnpm baseline:check` keeps `CMS:` comments and JSON blocks, so the saved baseline has to be saved again once: `pnpm baseline:save`; checked line by line that only those lines differ).
## Open points for the CMS host
See the report of this feature: the host renders the hero region only when the hero has a usable slide, and it writes picture/`h1` HTML without the lead. For this text-only site the region therefore stays the baked hero and the visitor gets the CMS text from the data block after the app has loaded. The site already styles the host's `cms-hero-*` classes (`src/index.css`) for the day the host can write a text-only region.