Last Modified Time

Output the last modified time of a document

Usage

This feature is not enabled by default, you can enable this from config file. Notice that it only supports Git as version control. When using git, please ensure you have Git installed on your local machine and the repository is not shallow cloned, as it relies on your local Git history.

import { defineConfig } from 'fumadocs-mdx/config';
 
export default defineConfig({
  lastModifiedTime: 'git',
});

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));
Edit on GitHub

Last updated on

On this page