feat(cms): 首页四项可配 + 开源页项目可见性 + GitHub README 开篇

- 首页:subtitle(markdown 短文本)|latestPhotos 0-6(0 隐藏)|
  perTrackLimit 4-8|sections{tracks,photos,heatmap,projects} 开关,
  访问器 homeConfig() 夹取越界值,字段级回落默认(零配置=原形态)
- 开源页项目可见性:mode all|only|exclude + include[]/exclude[] +
  sort pinned-first|stars|updated + perSource both|github|gitea;
  projects.ts 加 LoadProjectsOptions + arrange()(来源→可见性→排序)
- 开源页开篇支持 GitHub README:intro_from off|github-readme,构建期
  取 wait4xx/wait4xx README(token 复用宿主 0600 文件)→ 缓存
  content/.github-readme.md 入仓 → renderMarkdown;失败逐级回落
  (缓存 → yaml blurb)。实测取到 3117 字符,现状仍 off 待用户开启
- 修既有 bug:orderPinned 内硬 slice(0,6) 把开源页 limit=99 也截到 6 条
  → 移除,开源页恢复全量 16 条
- 文档:写作指南加首页/项目墙两张字段表(含 YAML 1.1 `off` 需加引号坑、
  README 行为与外部徽章风险说明)

车道:op-gitea(3/3);收编复验:构建 48 页 + E2E 37/37 + 开源页 16 条 +
首页默认形态(2 轨/热力图/项目墙)无回归

验证: node v26.13.0 构建 48 页 exit 0;E2E 37/37 PASS;playwright 实测

Spec: none (首页与开源页后台扩展,车道级交付)

Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-11-02 16:45:01 +08:00
1 parent 8d221ab36e
commit 859cac19a2
11 files changed
+387 -26

No files matched your search

+20 -6
View File
@@ -8,9 +8,12 @@ import PostList from '../../components/PostList.astro';
import ProjectWall from '../../components/geek/ProjectWall.astro';
import Heatmap from '../../components/geek/Heatmap.astro';
import { t } from '../../i18n/ui';
import { homeTagline } from '../../lib/site-content';
import { homeConfig, homeTagline, renderMarkdown } from '../../lib/site-content';
import SocialLinks from '../../components/SocialLinks.astro';
// 首页可配项(后台主页设置):副标题/影像张数/区块开关/每轨条数,字段级回落
const cfg = await homeConfig('en');
const subtitleHtml = cfg.subtitle ? await renderMarkdown(cfg.subtitle) : '';
const posts = (await getCollection('posts', ({ data }) => !data.draft && !data.tags.includes('hidden'))).sort(
(a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime(),
);
@@ -18,7 +21,7 @@ const posts = (await getCollection('posts', ({ data }) => !data.draft && !data.t
const enTitle = Object.fromEntries(
(await getCollection('postsEn')).map((e) => [e.id, e.data.title]),
);
const photos = (await getCollection('photos')).slice(0, 4);
const photos = (await getCollection('photos')).slice(0, Math.max(1, cfg.latestPhotos));
// 身份语与 zh 版同源(content/site/home.yaml 的 en 字段),缺值回落默认
const tagline = await homeTagline('en');
---
@@ -26,11 +29,13 @@ const tagline = await homeTagline('en');
<BaseLayout title="wait4x" description="wait4x's blog: reading · code · photography">
<IdCard>
<p class="tagline">{tagline}</p>
{subtitleHtml && <div class="subtitle" set:html={subtitleHtml} />}
<SocialLinks />
</IdCard>
<PostList {posts} locale="en" titleOverrides={enTitle} perTrack={6} />
{cfg.sections.tracks && <PostList {posts} locale="en" titleOverrides={enTitle} perTrack={cfg.perTrackLimit} />}
{cfg.sections.photos && cfg.latestPhotos > 0 && (
<section class="latest" aria-label={t('latest_photos', 'en')}>
<div class="latest-head">
<span class="lab">{t('latest_photos', 'en')}</span>
@@ -49,8 +54,9 @@ const tagline = await homeTagline('en');
))}
</div>
</section>
)}
<Heatmap
{cfg.sections.heatmap && <Heatmap
labels={{
title: t('heatmap_title', 'en'),
summary: t('heatmap_summary', 'en'),
@@ -58,11 +64,19 @@ const tagline = await homeTagline('en');
more: t('heatmap_more', 'en'),
note: t('heatmap_note', 'en'),
}}
/>
<ProjectWall locale="en" />
/>}
{cfg.sections.projects && <ProjectWall locale="en" />}
</BaseLayout>
<style>
.subtitle {
font-size: 13.5px;
color: var(--ink-4);
margin-top: 2px;
letter-spacing: 0.01em;
}
.subtitle :global(p) { margin: 0; }
.subtitle :global(a) { color: var(--accent); }
.tagline {
font-size: 14px;
color: var(--ink-3);