--- import { Image } from 'astro:assets'; import { getCollection } from 'astro:content'; import BaseLayout from '../../layouts/BaseLayout.astro'; import MomentComments from '../MomentComments.astro'; import ViewMeta from '../geek/ViewMeta.astro'; import { t } from '../../i18n/ui'; import { renderRich } from '../../lib/site-content'; import type { Locale } from '../../lib/locale'; // /en/ 侧由 T4 薄页传 locale='en';zh 路由无人传参,默认 zh 零回归 interface Props { locale?: Locale; } const { locale = 'zh' } = Astro.props; const moments = (await getCollection('moments')).sort( (a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime(), ); // 富文本预渲染(Phase 5h T2):text 走与页面文案同一条管线(markdown → 内容净化 → // class 白名单 → 链接卡片),因此瞬间支持 **加粗**、、列表与换行。 // 预渲染成 map 再进模板:renderRich 是 async,模板里不能 await。 // 纯文本老数据零回归:无 markdown 的文本会得到单个

,与旧的 {text} 直出视觉等价。 const richText = new Map(); for (const m of moments) { if (!m.data.text) continue; richText.set(m.id, await renderRich(m.data.text)); } const iso = (d: Date) => d.toISOString(); ---

{t('moments_title', locale)}

{t('moments_note', locale)}

    {moments.map((m) => (
  1. {m.data.image && (
    {m.data.text
    )} {m.data.text &&
    } {m.data.tags.length > 0 && (

    {m.data.tags.map((tag) => {`#${tag}`})}

    )}
  2. ))}