Skip to content

feat(docs): add homepage stats and recent updates - #36

Merged
mantoujun12 merged 4 commits into
mainfrom
feat/homepage-content
Sep 30, 2026
Merged

mantoujun12 merged 4 commits into
mainfrom
feat/homepage-content

Conversation

@mantoujun12

@mantoujun12 mantoujun12 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

The homepage only had a hero section and six feature cards. This PR adds a
content section below them and fixes a few issues found while reviewing the
change. The branch is rebased on the latest main (807f779).

Changes

Homepage content (docs/index.md)

  • Announcement block for class notices.
  • 站点速览 statistics cards (documents, sections, last update).
  • 最近更新 list built from the latest five content pages.
  • 热门直达 quick links to frequently used pages.

Build-time data loader (docs/.vitepress/data/updates.data.mts)

  • Collects page titles from frontmatter (or the first heading) and dates from
    git log -1, falling back to the file mtime when git is unavailable or the
    file has no commit yet.
  • Derives the page and section counts from the docs directory.
  • No extra dependencies and no runtime cost: the data is inlined as JSON at
    build time.

Follow-up fixes

  • ci: check out full git history — with the default fetch-depth: 1 every
    file reports the tip commit date, so the list showed five identical dates in
    alphabetical order.
  • fix(docs): stabilize homepage updates data — ESM file extension (.mts,
    removes a Vite configLoader warning), fixed UTC+8 date formatting so local
    and CI builds agree, the same page set for the list and the statistic, and a
    datetime attribute on the time element.

The duplicate-title problem that the review also found is already fixed on
main by #35 (docs/class/7s-original.md is now titled 学生宿舍 7S 管理标准(原始版)),
so this branch dropped its equivalent commit during the rebase.

Verification

  • pnpm docs:build passes with no build warnings.
  • The generated docs/.vitepress/dist/index.html contains 12 documents,
    4 sections and the five most recent pages with distinct titles, correct
    links and dates.
  • Local preview checked in a browser: the announcement, statistics, list and
    quick links render; the console has no Vue or hydration errors.

Notes

Not addressed here (possible follow-ups): links in the list use a plain <a>
and therefore trigger a full page load instead of SPA navigation, and the
timestamp field used for sorting is still serialized to the client.

- Add an announcement block, site statistics, a recent-updates list and
  quick links to the homepage.
- Add a build-time data loader (docs/.vitepress/data/updates.data.ts) that
  collects page titles and git last-commit dates, and derives the page and
  section counts from the docs directory.
- Document the new data directory in AGENTS.md.
The homepage recent-updates loader derives each page date from `git log`,
which reports the same tip date for every file on a shallow clone and
degrades the list to alphabetical order.
- Rename the loader to updates.data.mts so Vite loads it as ESM; this removes
  the configLoader/ESM-syntax build warning.
- Format page dates in a fixed time zone (UTC+8) so local and CI builds agree.
- Exclude the homepage from both the recent-updates list and the "last
  updated" statistic so the two stay consistent.
- Add datetime to the time element and document the rename in AGENTS.md.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 无阻塞问题 — 有一条小建议放在行内评论,其余核对都过了。

Reviewed changes

  • 首页内容扩展(docs/index.md) — hero/features 之下新增班级公告、站点速览 统计卡、最近更新 列表与 热门直达 快捷链接,多语言混排与全角标点均符合站内约定。
  • 构建期数据加载器(docs/.vitepress/data/updates.data.mts) — 新增 defineLoader:标题按 frontmatter → 首个 H1 → 文件名兜底;日期逐页取 git log -1,缺失时回退 mtime;时区固定东八区输出,本地与 CI 构建结果可复现。
  • CI 完整历史检出(.github/workflows/ci.yml) — checkout 加 fetch-depth: 0,否则浅克隆里每个文件 git log 都报 tip 日期,列表五条日期会完全相同。
  • 7S 原始页标题澄清(docs/class/7s-original.md) — frontmatter title 改为「宿舍 7S 原始内容」,与侧边栏文案一致,最近更新列表里两条 7S 不再重名。
  • AGENTS.md — 补充 docs/.vitepress/data/ 目录与 watch 相对解析的说明。

本地复跑了 pnpm docs:build,无警告;dist/index.html 与内联数据核对过:统计 12 页 / 4 栏目、top-5 链接和日期与 git log 一一对应,快捷链接目标全部存在。委员会验收 OK。评论区那条是防未来的健壮性小建议,不阻塞本次合并(作者在 PR Notes 里自己标记的两个跟进项也认可,不重复展开)。

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GLM Flash | 𝕏

Comment thread docs/.vitepress/data/updates.data.mts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 增量复查无新问题 — 唯一实质变化是 rebase 时删掉了本分支上那条 7S 标题提交,理由成立。

Reviewed changes

  • rebase 最新 main 后的分支调整 — 相对上轮(3315044)唯一的实际增量是移除了本分支修改 docs/class/7s-original.md frontmatter title 的提交:#35 已在 main 用「学生宿舍 7S 管理标准(原始版)」解决了同一个重名问题,本分支再改一遍只会徒增冲突,删得对。已复跑 pnpm docs:build(无警告),验证最近更新列表五条条目不再重名、统计卡仍为 12 页 / 4 栏目、热门直达 链接有效;ci.yml、AGENTS.md、updates.data.mts、docs/index.md 与上轮逐字节一致。

两件事顺带说明,都不阻塞本 PR:

  1. main 上 #35 改了页面标题但没同步 config.mts 侧边栏(/class/7s-original 的文案仍是「宿舍 7S 原始内容」,改成「学生宿舍 7S 管理标准(原始版)」更协调)——这属于 #35 的遗留,不在本 PR diff 范围内,留给后续处理。
  2. 上一轮评审里 extractTitle 围栏兜底那条行内小建议还挂着,不急于本次处理,作者改完我可以做最终放行。

Pullfrog  | Fix it ➔ | View workflow run | Using GLM Flash | 𝕏

Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 没有新问题——这轮唯一增量就是落实上轮那条围栏兜底的建议,可以合并了。

Reviewed changes

  • extractTitle 的 H1 兜底改为围栏感知(docs/.vitepress/data/updates.data.mts:52) — 在匹配 # 一级标题前先按首个 ``` 围栏截断,代码块里的 # 注释行(比如 bash 的 # 说明)不会再被当成页面标题。改动只在「没有 frontmatter title」的兜底分支生效,对现有 12 个页面零影响;我用含围栏注释的样例做了反例验证,行为符合预期。上轮的行内评论线程已回复并标记解决。

复核情况:pnpm docs:build 无警告;构建产物里统计仍为 12 页 / 4 栏目,最近更新五条标题、日期与上轮完全一致。ci.yml 与 AGENTS.md 相对上轮逐字节未动。PR 剩下的两个跟进项(列表用纯 <a> 不走 SPA 导航、timestamp 会序列化进客户端 payload)作者已在 Notes 里说明,属后续优化,不阻塞本次合并。

Pullfrog  | View workflow run | Using GLM Flash | 𝕏

@mantoujun12
mantoujun12 merged commit 4b8e555 into main Sep 30, 2026
3 checks passed
@mantoujun12
mantoujun12 deleted the feat/homepage-content branch September 30, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant