頁面歷史紀錄
在文件頁面上顯示貢獻者與 Git 歷史紀錄。
此為社群維護的整合。
fumadocs-page-history 可在文件頁面上顯示貢獻者,以及可摺疊的變更歷史紀錄。它會在建置時讀取 Git 歷史紀錄,並支援 Fumadocs MDX 與 Sätteri。
設定
需要 Node.js 24.14 以上版本,以及 16.x 版本系列中 16.17 以上的 Fumadocs。
安裝套件
npm install fumadocs-page-history註冊外掛
將 remarkGitChangelog 加入您的 docs 集合,並將 repoURL 設為您的儲存庫 URL。既有的 schema 與編譯器選項請保持不變。
import { applyMdxPreset, defineDocs } from 'fumadocs-mdx/config';
import { remarkGitChangelog } from 'fumadocs-page-history/remark';
export const docs = defineDocs({
dir: 'content/docs',
docs: {
mdxOptions: applyMdxPreset({
remarkPlugins: [[remarkGitChangelog, { repoURL: 'https://github.com/owner/repository' }]],
}),
},
});現在,此集合中每份文件的結尾都會顯示貢獻者與頁面歷史紀錄。無需修改頁面範本。
Git 歷史紀錄
建置環境需要安裝 Git,並取得儲存庫的完整歷史紀錄。在 GitHub Actions 中,請設定 fetch-depth: 0:
- uses: actions/checkout@v6
with:
fetch-depth: 0- 請在建置前先 commit 新檔案,才能納入其歷史紀錄。
- 有新的 commit 後請重新建置。開發期間,請重新啟動伺服器,才能讀取僅存在於 Git 中的變更。
設定
您可以分別啟用或停用貢獻者與歷史紀錄、自訂翻譯文字,也可以選擇解析 GitHub 大頭貼與個人檔案連結。
How is this guide?
最後更新於
