cms-client: hero uit het datablok #cms-data (parseHero, doelcontrole, titelregels en afgeleide kop, useCmsHero) met tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 16:48:55 +01:00
co-authored by Claude Sonnet 5.5
parent 02f3d9e931
commit 72dd381cf9
11 changed files with 364 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
/** The lines of a title: split on line breaks, trimmed, empty lines dropped. */
export function titleLines(title: string): string[] {
return title
.split(/\r\n|\r|\n/)
.map((line) => line.trim())
.filter((line) => line !== '');
}
/**
* The text for screen readers and search engines (the sr-only part of the `h1`): the brand prefix, a space and the
* title lines joined with single spaces. Without a prefix only the joined lines.
*/
export function headingFromLines(lines: readonly string[], prefix = ''): string {
const joined = lines.join(' ');
const start = prefix.trim();
return start === '' ? joined : `${start} ${joined}`;
}