---
// /en/ 首页:英文 UI + 双语内容(postsEn 优先,缺则中文回退)
import { getCollection } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { t } from '../../i18n/ui';
import IdCard from '../../components/IdCard.astro';
import { Image } from 'astro:assets';
const photos = (await getCollection('photos')).slice(0, 4);
import Heatmap from '../../components/geek/Heatmap.astro';
import { POST_TRACKS, trackOf } from '../../content.config';
const en = await getCollection('postsEn');
const zh = await getCollection('posts');
const bySlug = new Map(en.map((e) => [e.id, e]));
const posts = zh
.filter(({ data }) => !data.draft)
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf())
.map((p) => ({ zh: p, en: bySlug.get(p.id) }));
const years = [...new Set(posts.map((p) => p.zh.data.pubDate.getFullYear()))].sort((a, b) => b - a);
const t9 = (cat: keyof typeof POST_TRACKS) => trackOf(cat);
---
wait4x
↗
RSS
{years.map((year) => (
{year}
{(['reading', 'tech', 'photo'] as const).map((cat) => {
const list = posts.filter((p) => p.zh.data.category === cat && p.zh.data.pubDate.getFullYear() === year);
return list.length ? (
<>
{t(cat === 'reading' ? 'category_reading' : cat === 'tech' ? 'category_tech' : 'category_photo', 'en')}
>
) : null;
})}
))}