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
    -