Last Modified Time
Output the last modified time of a document
Usage
You can add the plugin from the config file.
Git is used by default
Please ensure you have Git installed on your machine, and the repository is not shallow cloned, as it relies on your local Git history.
import { defineConfig } from 'fumadocs-mdx/config';
import lastModified from 'fumadocs-mdx/plugins/last-modified';
export default defineConfig({
plugins: [lastModified()],
});Access the Property
After doing this, a lastModified number will be exported for each document. You can convert it to a JavaScript Date object.
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(new Date(page.data.lastModified));
// or with lazy loading
const { lastModified } = await page.data.load();
console.log(new Date(lastModified));How is this guide?
Last updated on
