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:
2026-11-16 16:48:00 +01:00
co-authored by Claude Sonnet 5.5
parent 13f78c48cd
commit ad0b114828
31 changed files with 863 additions and 134 deletions
+99 -26
View File
@@ -1,4 +1,5 @@
import type { HeroContent } from './types';
import { t } from '../i18n/index.ts';
import type { HeroData, HeroSlide } from '../lib/hero.ts';
// Images
import hero1 from '../assets/hero-1.jpg';
@@ -10,32 +11,104 @@ import hero6 from '../assets/hero-6.jpg';
import hero7 from '../assets/hero-7.jpg';
import hero8 from '../assets/hero-8.jpg';
// Statische content tot de CMS-API er is. Daarna komt dit object uit de API.
const heroContent: HeroContent = {
title: 'Andrea Slop',
tagline: 'Lifestyle fotograaf · Huizen',
cta: { label: 'Lees meer', to: '/over-mij' },
// The hero the build bakes into the page: what the visitor sees until the CMS
// host (or the API) gives another one, and again when that fails. The same
// shape as what the CMS gives (lib/hero), so one component shows both. The
// photos have no wide/tall variants: the plain file is used everywhere.
// focus: where the subject is (0..1), used as object-position.
const slide = (
id: string,
src: string,
alt: string,
width: number,
height: number,
x: number,
y: number,
): HeroSlide => ({
id,
alt,
decorative: false,
image: { width, height, focus: { x, y }, src, variants: [] },
});
const heroContent: HeroData = {
display: 'slideshow',
title: t('hero.baked.title'),
tagline: t('hero.baked.tagline'),
buttons: [{ label: t('hero.baked.button'), target: '/over-mij' }],
slides: [
{ id: 'hero-8', src: hero8, alt: 'Zwangerschapsfoto in de duinen' },
{ id: 'hero-7', src: hero7, alt: 'Knusse newbornfoto met de familie' },
{
id: 'hero-1',
src: hero1,
alt: 'Lifestyle fotografie',
},
{
id: 'hero-2',
src: hero2,
alt: 'Zwangerschapsshoot in de buitenlucht',
},
{
id: 'hero-3',
src: hero3,
alt: 'Newbornshoot van een pasgeboren baby',
},
{ id: 'hero-4', src: hero4, alt: 'Spontaan portret buiten' },
{ id: 'hero-5', src: hero5, alt: 'Natuurlijke lifestylefoto' },
{ id: 'hero-6', src: hero6, alt: 'Portret in de natuur' },
slide(
'hero-8',
hero8,
t('hero.baked.alt.hero8'),
1600,
1067,
0.5,
0.55,
),
slide(
'hero-7',
hero7,
t('hero.baked.alt.hero7'),
1600,
1067,
0.45,
0.5,
),
slide(
'hero-1',
hero1,
t('hero.baked.alt.hero1'),
2560,
1702,
0.55,
0.6,
),
slide(
'hero-2',
hero2,
t('hero.baked.alt.hero2'),
1600,
1067,
0.45,
0.45,
),
slide(
'hero-3',
hero3,
t('hero.baked.alt.hero3'),
1600,
1067,
0.45,
0.4,
),
slide(
'hero-4',
hero4,
t('hero.baked.alt.hero4'),
2048,
1362,
0.45,
0.35,
),
slide(
'hero-5',
hero5,
t('hero.baked.alt.hero5'),
1600,
1067,
0.5,
0.55,
),
slide(
'hero-6',
hero6,
t('hero.baked.alt.hero6'),
2048,
1362,
0.5,
0.35,
),
],
};