Author SHA1 Message Date
wait4xandGLM-5.3 3e09a362cc refactor(home): 首页三字段默认值收敛到 SITE_DEFAULTS(5g T4 补)
- SITE_DEFAULTS 新增 homeProjectsLimit=6 / homeAnnouncement(空) /
  homePostsTracks(全开),访问器改为引用默认常量而非散落字面量
- 旧 yaml(无三字段)零回归实测:公告不渲染、项目墙默认 6 条、三轨全开

验证: 构建 48 页 exit 0;E2E 37/37(快照口径)

Spec: 2026-11-02_blog-5g-pages (T3/T4 补充)

Co-authored-by: GLM-5.3
2026-11-02 19:02:41 +08:00
+11 -5
View File
@@ -12,6 +12,12 @@ export interface Bi {
/** 与仓库现状逐字一致的默认文案:yaml 全空时产物不变(零回归可视验证锚点) */
export const SITE_DEFAULTS = {
/** 首页项目墙条数(旧 yaml 无此字段时的默认:6 条) */
homeProjectsLimit: 6,
/** 首页公告(默认空 = 不渲染) */
homeAnnouncement: { zh: '', en: '' },
/** 首页轨细分(默认全开 = 现状) */
homePostsTracks: { reading: true, tech: true, photo: true },
homeTagline: {
zh: '写作者 · 读者 · 快门按压者,拥抱开源。',
en: 'Writer · Reader · Shutter-presser — embracing open source.',
@@ -256,12 +262,12 @@ export async function homeConfig(locale: Locale): Promise<HomeConfig> {
const d = entry?.data;
return {
subtitle: pickBi(d?.subtitle, { zh: '', en: '' }, locale),
announcement: pickBi(d?.announcement, { zh: '', en: '' }, locale),
projectsLimit: clampInt(d?.projectsLimit, 1, 99, 6),
announcement: pickBi(d?.announcement, SITE_DEFAULTS.homeAnnouncement, locale),
projectsLimit: clampInt(d?.projectsLimit, 1, 99, SITE_DEFAULTS.homeProjectsLimit),
postsTracks: {
reading: d?.postsTracks?.reading ?? true,
tech: d?.postsTracks?.tech ?? true,
photo: d?.postsTracks?.photo ?? true,
reading: d?.postsTracks?.reading ?? SITE_DEFAULTS.homePostsTracks.reading,
tech: d?.postsTracks?.tech ?? SITE_DEFAULTS.homePostsTracks.tech,
photo: d?.postsTracks?.photo ?? SITE_DEFAULTS.homePostsTracks.photo,
},
latestPhotos: clampInt(d?.latestPhotos, 0, 6, 4),
perTrackLimit: clampInt(d?.perTrackLimit, 4, 8, 6),