From 7e0167a8bbe5d4ade9de8ba590b53b379c32952c Mon Sep 17 00:00:00 2001 From: wait4xx Date: Wed, 4 Nov 2026 20:09:10 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat(opensource):=20=E7=83=AD=E5=8A=9B?= =?UTF-8?q?=E5=9B=BE=E4=BA=94=E6=96=B9=E6=A1=88=E9=A2=84=E8=A7=88=20+=20?= =?UTF-8?q?=E5=BC=80=E6=BA=90=E9=A1=B5=E5=8F=99=E8=BF=B0=E5=90=88=E4=B8=80?= =?UTF-8?q?=EF=BC=885j=20T1=20+=20=E9=A2=84=E8=AE=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户两项新需求: ①「开源页的叙述为什么要区分链接前和链接后?完全可以用 markdown 富文本统一替代」 ②「热力图可以有更多的动效,而不是静态的一张图,探索相关方案供我审阅」 T1 叙述合一: - opensource.yaml 新增 story(双语 markdown,链接内联),blurb/blurb_after 保留为 legacy(story 为空时才用)→ 旧 yaml 零回归 - site-content 访问器取 story,GithubProfile 走 renderRich 行内模式;markdown 生成的 裸 补 .pf-bio :global(a) 样式,与 .pf-link 观感一致 - 实测产物:pf-bio 内联 渲染成功、pf-link 拼接痕迹 0 处 热力图五方案预览(/heatmap-preview/,供用户选型): - 新增 geek/HeatGrid.astro:可复用网格渲染件(371 格带 --c/--r 供错峰延迟), 沿用线上同款 ink 灰阶(accent 只做高亮,不参与数据编码) - A 入场波纹(视口内一次性斜向漫过)、B 光标光晕(radial-gradient 跟随 + 日期读数)、 C 年度回放(滑块 scrub + 累计计数 + 自动播放)、D 连续电流(最近连续段流光 + 连续天数大数)、E 悬停周详情(整列抬起 + 周合计/最好一天面板) - 五案均守灰阶红线、均在 prefers-reduced-motion 下静态化、零第三方依赖、无常驻 rAF - **两处真坑**:①网格是子组件渲染,页面级 scoped 样式够不到其内部元素 → 与格内元素 相关的选择器必须 :global()(否则 A 的动画与 E 的抬列静默不生效)②「当前连续」按 今天起算会得 0(今天尚未贡献)→ 改为以最后一个有贡献的日子为终点往回数,并标注 「截至 <日期>」 另修 E2E 过时断言:书架改版为抽书阅读后,原「年份折叠组」断言必然失败, 改为「抽书行渲染 + 点击可抽开」(56/56 PASS) 验证: 构建 51 页 exit 0;content-lint 52 页 0/0/0;E2E 56/56; Playwright 逐案实测:A 动画 hmRise 0.42s 且播完 opacity=1、B 光晕 opacity=1 并显示「日期 · 次数」、C 拖到第 10 周读数与淡出正确、D 12 格流光 hmFlow + 连续 5 天(截至 2026-10-24)、E 整列 lift matrix(…,-2);390 零横向溢出; reduced-motion 下动画 none、光晕 display:none Spec: 2026-11-03_blog-5j-content-refine (T1 + 热力图预览) Co-authored-by: GLM-5.3 --- content/site/opensource.yaml | 9 + scripts/build-perf/content-lint.mjs | 4 + src/components/geek/GithubProfile.astro | 21 +- src/components/geek/HeatGrid.astro | 58 ++++ src/content.config.ts | 26 ++ src/lib/site-content.ts | 81 +++++ src/pages/heatmap-preview.astro | 400 ++++++++++++++++++++++++ tests/e2e.mjs | 13 +- 8 files changed, 604 insertions(+), 8 deletions(-) create mode 100644 src/components/geek/HeatGrid.astro create mode 100644 src/pages/heatmap-preview.astro diff --git a/content/site/opensource.yaml b/content/site/opensource.yaml index 5041226..765d4df 100644 --- a/content/site/opensource.yaml +++ b/content/site/opensource.yaml @@ -9,11 +9,20 @@ typing: - zh: 书与快门都在一个工作台 en: Books and shutters, one workbench +# 开篇叙述(5j T1):markdown 富文本,链接内联写 `[文字](url)`。 +# 非空时整段走富文本管线(净化 + 排版类白名单),**取代**下面的 blurb + repo_* + blurb_after 拼接。 +story: + zh: "本站本身即开源:[git.wait4x.online/wait4x/blog](https://git.wait4x.online/wait4x/blog) —— Astro SSG、双写作流、构建发布全链皆在仓中。以下是我在自托管 gitea 与 GitHub 上的全部公开仓库,以及最近一年的贡献活动。" + en: "This site is itself open source: [git.wait4x.online/wait4x/blog](https://git.wait4x.online/wait4x/blog) — the Astro SSG, dual-writing workflow, and the full build & deploy pipeline live in the repo. Below are all my public repositories on self-hosted gitea and GitHub, plus contributions from the past year." + +# ---- legacy(story 为空时才用)---- +# 下面四个字段是 5j 之前「两半夹链接」的写法,保留只为旧 yaml / 回退演示;新改动请一律写 story。 blurb: zh: 本站本身即开源: en: 'This site is itself open source:' repo_url: https://git.wait4x.online/wait4x/blog repo_label: git.wait4x.online/wait4x/blog +# legacy:story 为空时接在 story 占位处拼接(见上方 blurb 注释) blurb_after: zh: —— Astro SSG、双写作流、构建发布全链皆在仓中。以下是我在自托管 gitea 与 GitHub 上的全部公开仓库,以及最近一年的贡献活动。 en: — the Astro SSG, dual-writing workflow, and the full build & deploy pipeline live in the repo. Below are all my public repositories on self-hosted gitea and GitHub, plus contributions from the past year. diff --git a/scripts/build-perf/content-lint.mjs b/scripts/build-perf/content-lint.mjs index cbeb089..f711ccb 100644 --- a/scripts/build-perf/content-lint.mjs +++ b/scripts/build-perf/content-lint.mjs @@ -16,6 +16,9 @@ if (MODE === 'skip') { const SKIP_PREFIX = ['/admin/', '/photos-originals/']; // admin=CMS 路由;photos-originals=部署期 rsync 叠加层(不在 dist,另有部署链保障) const SKIP_FILE = new Set(['/404.html']); // Astro 404 页不参与配对 +// 一次性预览路由(无 en 对应页):完全不参与检查。用户选定方案后随路由一起删除。 +const SKIP_ALL = new Set(['/heatmap-preview/index.html']); + function walk(dir, out = []) { for (const e of readdirSync(dir)) { @@ -50,6 +53,7 @@ const warns = []; for (const f of files) { const rel = f.slice(DIST.length) || '/'; + if (SKIP_ALL.has(rel)) continue; const html = readFileSync(f, 'utf8'); // 站内 :仅根相对路径;#锚点/mailto/tel/外部/data: 全跳过 diff --git a/src/components/geek/GithubProfile.astro b/src/components/geek/GithubProfile.astro index 4ede507..b728d3c 100644 --- a/src/components/geek/GithubProfile.astro +++ b/src/components/geek/GithubProfile.astro @@ -7,7 +7,7 @@ import { Image } from 'astro:assets'; import { existsSync } from 'node:fs'; import TypingLines from './TypingLines.astro'; -import { homeAvatar, homeSocials, openSourceCopy } from '../../lib/site-content'; +import { homeAvatar, homeSocials, openSourceCopy, renderRich } from '../../lib/site-content'; import { githubUserStats, loadProjects } from '../../lib/projects'; import { iconPath } from '../../lib/icons'; import type { Locale } from '../../lib/locale'; @@ -20,6 +20,10 @@ const { locale = 'zh' } = Astro.props; const avatar = await homeAvatar(); const socials = await homeSocials(); const copy = await openSourceCopy(locale); +// 开篇叙述合一(5j T1):story 非空 → 整段走富文本管线(markdown + 内容净化 + 排版类白名单), +// 链接就是 markdown 普通链接,不再需要 blurb/blurb_after 两半夹一个 repo 链接; +// story 为空 → 回落旧的 blurb + + blurb_after 拼接(旧 yaml 零回归)。 +const storyHtml = copy.story.trim() ? await renderRich(copy.story, { inline: true }) : null; // 仓库数据:档案卡只关心"语言占比 + 星标汇总",取全量(不受项目墙可见性影响) let langs: { name: string; count: number; pct: number }[] = []; @@ -105,9 +109,13 @@ const L = { wait4x@wait4xx

-

- {copy.blurb}{copy.repoLabel}{' '}{copy.blurbAfter.trim()} -

+ {storyHtml ? ( +

+ ) : ( +

+ {copy.blurb}{copy.repoLabel}{' '}{copy.blurbAfter.trim()} +

+ )}