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,33 @@
|
||||
import { headingFromLines, titleLines, type CmsHero, type CmsHeroButton } from '../../../cms-client/hero';
|
||||
import { heroContent } from './content';
|
||||
|
||||
/** What the hero components show: from the CMS when it delivered a hero, otherwise the baked texts. */
|
||||
export interface ResolvedHero {
|
||||
/** Text for screen readers and search engines (the sr-only part of the h1). */
|
||||
heading: string;
|
||||
/** The visible title, one entry per line. */
|
||||
lines: string[];
|
||||
lead: string | null;
|
||||
buttons: CmsHeroButton[];
|
||||
fromCms: boolean;
|
||||
}
|
||||
|
||||
export function resolveHero(cms: CmsHero | null): ResolvedHero {
|
||||
if (cms === null) {
|
||||
return {
|
||||
heading: heroContent.heading,
|
||||
lines: heroContent.displayHeading,
|
||||
lead: heroContent.lead,
|
||||
buttons: heroContent.buttons,
|
||||
fromCms: false,
|
||||
};
|
||||
}
|
||||
const lines = titleLines(cms.title);
|
||||
return {
|
||||
heading: headingFromLines(lines, heroContent.headingPrefix),
|
||||
lines,
|
||||
lead: cms.lead,
|
||||
buttons: cms.buttons,
|
||||
fromCms: true,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user