--- // 贡献热力图(极客层 P0):纯 CSS grid,零运行时 JS // 数据聚合见 src/lib/heatmap.ts;灰阶四档直接复用 tokens --ink-1..4(亮暗两套自动跟随) import { loadHeatmap, levelOf, streakStats } from '../../lib/heatmap'; import { localeOf } from '../../lib/locale'; // 文案全部由页面层注入(locale 无关挂法),keys 与 ui.ts heatmap_* 一一对应 interface Labels { title: string; summary: string; // 含 {n} 占位符 less: string; more: string; note: string; } interface Props { labels: Labels; } const { labels } = Astro.props; const locale = localeOf(Astro.url.pathname); let weeks: import('../../lib/heatmap').HeatDay[][] = []; let total = 0; try { ({ weeks, total } = await loadHeatmap()); } catch { // 三级回落已在 lib 内处理;此处再守一层:空网格不破构建 } // 连续贡献(Phase 5j T2):与热力图同源本地计算 + 标注更新时间(不宣称实时) const streak = streakStats(weeks.flat()); const updatedOn = new Date().toISOString().slice(0, 10); const summary = labels.summary.replace('{n}', String(total)); ---

{labels.title}

{streak.current}{locale === 'en' ? 'day streak' : '天连续'} {streak.longest}{locale === 'en' ? 'longest' : '最长'} {streak.total}{locale === 'en' ? 'total' : '总贡献'} 数据更新于 {updatedOn}

{[0, 1, 2, 3, 4].map((l) => (