跳至內容
Fumadocs

最後修改時間

輸出文件的最後修改時間

使用方式

您可以在設定檔中加入此外掛。

預設使用 Git

請確認您的電腦已安裝 Git,且儲存庫並非透過淺層複製 (shallow clone) 取得,因為此功能需要讀取您本機的 Git 歷史紀錄。

source.config.ts
import { defineConfig } from 'fumadocs-mdx/config';
import lastModified from 'fumadocs-mdx/plugins/last-modified';

export default defineConfig({
  plugins: [lastModified()],
});

存取屬性

完成後,每份文件都會匯出 lastModified 屬性 (型別為 Date) 。

import { source } from '@/lib/source';

const page = source.getPage(['...']);

console.log(page.data.lastModified);
// 或使用延遲載入
const { lastModified } = await page.data.load();
console.log(lastModified);

您可以透過 <DocsPage /> 等 UI 元件來顯示此資訊

How is this guide?

最後更新於