home3 news headline: drop JS char-slice, use CSS line-clamp:2 (word-boundary, fills 2 lines)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,14 +9,8 @@
|
|||||||
let art = $state(null); // {title, artist, year, image}
|
let art = $state(null); // {title, artist, year, image}
|
||||||
let newsFit = $state('cover'); // 'cover' = full-bleed photo; 'contain' = framed-plate figure
|
let newsFit = $state('cover'); // 'cover' = full-bleed photo; 'contain' = framed-plate figure
|
||||||
|
|
||||||
// headline truncated on a whole-word boundary (no mid-word ellipsis)
|
// truncation handled by CSS (-webkit-line-clamp:2) — breaks on whole words, fills 2 full lines
|
||||||
function clampWords(s, max = 48) {
|
let headline = $derived(news?.title ?? 'What went right this week: the good news that actually matters');
|
||||||
if (!s || s.length <= max) return s;
|
|
||||||
const cut = s.slice(0, max);
|
|
||||||
const i = cut.lastIndexOf(' ');
|
|
||||||
return (i > 0 ? cut.slice(0, i) : cut).replace(/[\s,;:.]+$/, '') + '…';
|
|
||||||
}
|
|
||||||
let headline = $derived(clampWords(news?.title ?? 'What went right this week: the good news that actually matters'));
|
|
||||||
|
|
||||||
// small-joys shelf: 3 cells shown two at a time, rotated by the reader (no auto-motion)
|
// small-joys shelf: 3 cells shown two at a time, rotated by the reader (no auto-motion)
|
||||||
const JOY_ACCENTS = ['#4f7da8', '#b06a86', '#b06a45'];
|
const JOY_ACCENTS = ['#4f7da8', '#b06a86', '#b06a45'];
|
||||||
|
|||||||
Reference in New Issue
Block a user