--- import { categoryMeta, formatShortDate, type Post } from '../lib/posts'; interface Props { post: Post; variant: 'hero' | 'compact'; } const { post, variant } = Astro.props; const { entry, category, url, date } = post; const { title, image, excerpt } = entry.data; const { tag, tagcls } = categoryMeta(category); const shortDate = formatShortDate(date); function truncate(s: string | undefined, n: number): string { const t = (s ?? '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n).replace(/\s+\S*$/, '') + '…' : t; } --- {variant === 'hero' ? (
{tag}

{title}

{truncate(excerpt, 160)}

Read
) : (
{tag}

{title}

{truncate(excerpt, 105)}

)}