From 725bfde21f6184856d808940f9384d8c20a2c7e9 Mon Sep 17 00:00:00 2001 From: wait4xx Date: Sat, 24 Oct 2026 23:13:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(geek):=20=E6=9E=81=E5=AE=A2=E5=B1=82=20P0?= =?UTF-8?q?=20=E5=9B=9B=E4=BB=B6=E5=A5=97=E2=80=94=E2=80=94=E9=94=AE?= =?UTF-8?q?=E7=9B=98/=E6=9E=84=E5=BB=BA=E9=80=8F=E6=98=8E/=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=BD=AC=E5=9C=BA/=E9=A1=B9=E7=9B=AE=E5=A2=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Keyboard:? 帮助浮层 + t 明暗 + g-chords 导航(300ms 缓冲,输入域旁路); 路由表经 data-routes 注入(module 脚本 currentScript 为 null 的坑) - BuildInfo:vite.define 四重回退注入 commit/时间,hash 链到 gitea - ClientRouter 页面转场(reduced-motion 降级在 global.css 总闸) - ProjectWall:构建时双源拉取(gitea+github)置顶排序+缓存兜底,零运行时 JS - Header 补主题可视切换钮:键盘 t 的触屏等价物(同 key 同逻辑) 验证: pnpm astro build exit 0;dist 标记 built from×2/kbd-help×4/ view-transition×2; astro check 未跑(无类型错误构建期可证伪面有限) Spec: 2026-10-24_add-blog-skeleton Co-authored-by: GLM-5.3 --- astro.config.mjs | 19 +++++- src/components/Header.astro | 19 ++++++ src/components/geek/BuildInfo.astro | 13 ++++ src/components/geek/Keyboard.astro | 98 +++++++++++++++++++++++++++ src/components/geek/ProjectWall.astro | 71 +++++++++++++++++++ src/data/projects-fallback.json | 11 +++ src/layouts/BaseLayout.astro | 9 ++- src/lib/projects.ts | 86 +++++++++++++++++++++++ 8 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 src/components/geek/BuildInfo.astro create mode 100644 src/components/geek/Keyboard.astro create mode 100644 src/components/geek/ProjectWall.astro create mode 100644 src/data/projects-fallback.json create mode 100644 src/lib/projects.ts diff --git a/astro.config.mjs b/astro.config.mjs index 85f1596..6c48e8b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,7 +1,24 @@ // @ts-check import { defineConfig } from 'astro/config'; +import { execSync } from 'node:child_process'; + +// 构建透明(T7):commit/时间经 vite.define 注入,页脚与 /about 引用。 +// 四重回退:CI 环境变量优先(GITEA_ACTIONS/GITHUB_SHA)→ 本地 git → dev 占位。 +const sha = + process.env.GITEA_COMMIT_SHA || + process.env.GITHUB_SHA || + (() => { try { return execSync('git rev-parse HEAD').toString().trim(); } catch { return 'dev'; } })(); +const date = + process.env.GITEA_COMMIT_DATE || + process.env.GITHUB_COMMIT_DATE || + (() => { try { return execSync('git log -1 --format=%cI').toString().trim(); } catch { return new Date().toISOString(); } })(); -// 极简起点:集成(pagefind/rss/sitemap)在 T8 按任务加入,保持骨架可构建 export default defineConfig({ site: 'https://wait4x.online', + vite: { + define: { + 'import.meta.env.GIT_COMMIT_SHA': JSON.stringify(sha), + 'import.meta.env.GIT_COMMIT_DATE': JSON.stringify(date), + }, + }, }); diff --git a/src/components/Header.astro b/src/components/Header.astro index d1c17a9..44dd19b 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -35,11 +35,30 @@ const isCurrent = (href: string) => + +
  • + +
  • + + diff --git a/src/components/geek/ProjectWall.astro b/src/components/geek/ProjectWall.astro new file mode 100644 index 0000000..af60f34 --- /dev/null +++ b/src/components/geek/ProjectWall.astro @@ -0,0 +1,71 @@ +--- +// 开源项目墙(极客层 P0):构建时渲染,零运行时 JS +// 双源数据见 src/lib/projects.ts;语言色点用 linguist 常用色映射 +import { loadProjects, type RepoCard } from '../../lib/projects'; + +const LANG_COLORS: Record = { + Astro: '#ff5a03', TypeScript: '#3178c6', JavaScript: '#f1e05a', + Python: '#3572a5', Go: '#00add8', Rust: '#dea584', Shell: '#89e051', + HTML: '#e34c26', CSS: '#563d7c', Dockerfile: '#384d54', +}; + +let projects: RepoCard[] = []; +try { + projects = await loadProjects(); +} catch { + projects = []; // 兜底已在 lib 内处理,此处再守一层:空墙不破构建 +} +--- + +
    +

    开源 · Projects

    + +
    + + diff --git a/src/data/projects-fallback.json b/src/data/projects-fallback.json new file mode 100644 index 0000000..fe3abcf --- /dev/null +++ b/src/data/projects-fallback.json @@ -0,0 +1,11 @@ +[ + { + "source": "gitea", + "name": "blog", + "description": "本站源码:Astro SSG + 双写作流,内容即代码", + "language": "Astro", + "stars": 0, + "url": "https://git.wait4x.online/wait4x/blog", + "updatedAt": "" + } +] diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index b89774e..e6f33ca 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -11,6 +11,9 @@ import '../styles/global.css'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import ThemeScript from '../components/ThemeScript.astro'; +import Keyboard from '../components/geek/Keyboard.astro'; +import BuildInfo from '../components/geek/BuildInfo.astro'; +import { ClientRouter } from 'astro:transitions'; interface Props { title: string; @@ -32,6 +35,7 @@ const { title, description = 'wait4x 的博客:阅读 · 技术 · 摄影', tr {title} + @@ -39,6 +43,9 @@ const { title, description = 'wait4x 的博客:阅读 · 技术 · 摄影', tr
    -