diff --git a/src/components/PostList.astro b/src/components/PostList.astro index af3f718..8a05c60 100644 --- a/src/components/PostList.astro +++ b/src/components/PostList.astro @@ -2,13 +2,22 @@ // 年份分组 + 轨道分节的文章列表(首页与 /archives/ 共用) // 轨道标签单一事实源:content.config 的 POST_TRACKS,此处不另立词表 import type { CollectionEntry } from 'astro:content'; -import { POST_TRACKS, trackOf, type PostCategory } from '../content.config'; +import { POST_TRACKS, type PostCategory } from '../content.config'; +import { t } from '../i18n/ui'; interface Props { /** 调用方已完成 draft 过滤与 pubDate 倒序 */ posts: CollectionEntry<'posts'>[]; + locale?: 'zh' | 'en'; } -const { posts } = Astro.props; +const { posts, locale = 'zh' } = Astro.props; +// 轨道标签走字典(en 首页复用本组件时的双语位);zh 保持原词表语义 +const TRACK_LABEL: Record = { + reading: t('category_reading', locale), + tech: t('category_tech', locale), + photo: t('category_photo', locale), +}; +const hrefOf = (id: string) => (locale === 'en' ? `/en/archives/${id}/` : `/archives/${id}/`); const byYear = new Map[]>(); for (const post of posts) { @@ -30,11 +39,11 @@ const mmdd = (d: Date) => if (rows.length === 0) return null; return (
-

{trackOf(cat)}

+

{TRACK_LABEL[cat]}