⚠️ 2026-04-11 ε 起:這條 pipeline 已經被 DATA-REFRESH-PIPELINE.md 的 Step 4 取代。直接跑bash scripts/tools/refresh-data.sh就會包含本文件描述的所有步驟。本檔案保留作為
update-stats.sh腳本本身的參考文檔,說明它做了什麼、不能動什麼。
git pull → update-stats.sh → git add (指定檔案) → commit → push
cd ~/taiwan-md && git pullbash scripts/tools/update-stats.sh腳本做的事:
- 從 GitHub API 抓 stars / forks / contributors 數字
- 更新
README.md的統計表格 - 更新
src/i18n/about.ts的 About 頁面數字(四捨五入到百位) - Merge GitHub 數據到
public/api/stats.json(保留既有欄位) - 跑
generate-content-stats.js更新內容統計
git add README.md src/i18n/about.ts public/api/stats.json src/data/content-stats.json
git diff --cached --quiet || (git commit -m "chore: daily stats update" && git push)只 add 上面 4 個檔案。git add -A 會把其他人正在改的東西一起 commit。
Contributors grid 由另一個 Cron(Taiwan.md Contributors Update)管理。Stats cron 動到 about.template.astro = 破壞 Sponsors + Contact section。已經發生過 3 次。
public/api/stats.json 由兩個來源共同維護:
generate-content-stats.js:categories、tags、subcategories 等豐富內容(主要來源)update-stats.sh:stars、forks、contributors(GitHub API 即時數據)
腳本只更新 GitHub 欄位,保留其他所有既有欄位。如果整個覆寫 = Dashboard 資料全丟。
腳本在 scripts/tools/,用 cd "$(dirname "$0")/../.." 回到 repo root。不是 ..(那只到 scripts/)。
| 檔案 | 用途 |
|---|---|
scripts/tools/update-stats.sh |
主腳本 |
scripts/tools/generate-content-stats.js |
內容統計(categories/tags) |
public/api/stats.json |
統一 stats API(Dashboard + About 頁共用) |
src/i18n/about.ts |
About 頁面顯示數字 |
src/data/content-stats.json |
Build-time 內容統計 |
| Cron | 時間 | 職責 |
|---|---|---|
| Taiwan.md Daily Stats Update | 00:00 | 本 pipeline |
| Taiwan.md Contributors Update | 03:30 | 更新 contributor 名單 + README 表格 |
版本:v1.0 | 2026-03-29