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:
jay
2026-06-22 13:20:32 -04:00
parent 319c5f6b7e
commit 18e950bbf7
+2 -8
View File
@@ -9,14 +9,8 @@
let art = $state(null); // {title, artist, year, image}
let newsFit = $state('cover'); // 'cover' = full-bleed photo; 'contain' = framed-plate figure
// headline truncated on a whole-word boundary (no mid-word ellipsis)
function clampWords(s, max = 48) {
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'));
// truncation handled by CSS (-webkit-line-clamp:2) — breaks on whole words, fills 2 full lines
let headline = $derived(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)
const JOY_ACCENTS = ['#4f7da8', '#b06a86', '#b06a45'];