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:
@@ -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.
|
||||
@@ -31,12 +31,12 @@ A key is a dotted path: the namespace, then the section, then the element, for e
|
||||
|
||||
## What is deliberately not in the language files
|
||||
|
||||
- The Hero (component and hero data): it becomes a CMS module.
|
||||
- The title, lead and buttons of the Hero: they come from the CMS (data block `#cms-data`, see `docs/hero-integration.md`). The baked fallback texts of the Hero and its fixed lines (small line, code line, brand prefix of the heading) are in the language file, block `home.hero`.
|
||||
- Everything that comes from the CMS: packages, banners, and so on.
|
||||
- `src/cms-client`: it is a movable package and has its own messages (`messages.nl.ts`); it may not import from the app.
|
||||
- The privacy statement: it is its own feature and has its own text.
|
||||
|
||||
ESLint knows these exceptions: `react/jsx-no-literals` and a rule for text attributes (`aria-label`, `aria-description`, `alt`, `title`, `placeholder`, `label`) warn about a text typed straight into JSX in `src/**/*.tsx`, except in the Hero, tests and the privacy statement. Single technical signs (`/`, `|`, `-`, `:`, and so on), whitespace and numbers are allowed. They are warnings for now; they become errors when the move is done.
|
||||
ESLint knows these exceptions: `react/jsx-no-literals` and a rule for text attributes (`aria-label`, `aria-description`, `alt`, `title`, `placeholder`, `label`) warn about a text typed straight into JSX in `src/**/*.tsx`, except in tests and the privacy statement. Single technical signs (`/`, `|`, `-`, `:`, and so on), whitespace and numbers are allowed. They are warnings for now; they become errors when the move is done.
|
||||
|
||||
## Adding a second language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user