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:
@@ -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}`;
|
||||
}
|
||||
Reference in New Issue
Block a user