homepage: bento 3-up + 300x600 inline; word-safe excerpt; bigger sponsor logos
- FeaturedBentoFromDb: row below the hero is now a 3-up rail on the left with the Blackmagic 300x600 on the right, aligned with the hero's right edge. SidebarAdStack skips that 300x600 so the article-feed sidebar starts with the 300x250 stack instead. - cleanExcerpt: render-time word-snap for excerpts that were hard-cut at a byte count (Matrox 50-years showed "Since 1976, the co" mid-word). Used on the bento hero subhead and the article-feed cards. - SponsorLogoStrip: now also pulls every tracked_companies.featured=true brand (Rode, TBC Consoles, Plura, Autocue, Autoscript, Filmcraft, Lectrosonics, Prompter People, SanDisk, Sennheiser), and logos go from h-10/h-12 max-w-140 → h-14/h-16 max-w-180 with thicker padding. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
21
src/lib/articles/excerpt.ts
Normal file
21
src/lib/articles/excerpt.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// Render-time excerpt sanitizer. Some imported / AI-generated excerpts were
|
||||
// hard-truncated at a fixed byte count, leaving sentences clipped mid-word
|
||||
// (e.g. "Since 1976, the co"). Until the upstream excerpt generator gets the
|
||||
// same treatment, this helper makes any clipped excerpt visually clean:
|
||||
// strip trailing junk, snap to the last complete word, and append an
|
||||
// ellipsis only when the excerpt isn't already a complete sentence.
|
||||
|
||||
const SENTENCE_END = /[.!?…]['")\]]?$/;
|
||||
const TRAILING_JUNK = /[\s,;:—–\-—_]+$/;
|
||||
|
||||
export function cleanExcerpt(raw: string | null | undefined): string {
|
||||
if (!raw) return "";
|
||||
let s = raw.replace(/ /g, " ").trim();
|
||||
if (!s) return "";
|
||||
if (SENTENCE_END.test(s)) return s;
|
||||
// Drop the trailing partial token.
|
||||
const lastSpace = s.lastIndexOf(" ");
|
||||
if (lastSpace > 20) s = s.slice(0, lastSpace);
|
||||
s = s.replace(TRAILING_JUNK, "");
|
||||
return s + "…";
|
||||
}
|
||||
Reference in New Issue
Block a user