Advanced API
Read Git history for custom layouts or content pipelines.
The compiler plugin handles normal setup. Use these APIs only for a custom layout or content pipeline.
Read history
Read Git in a Node server module or build script, then pass the result to the UI:
import 'server-only';
import { readPageHistory } from 'fumadocs-page-history/git';
import { GitChangelog } from 'fumadocs-page-history/ui';
export async function PageHistory({ path }: { path: string }) {
const commits = await readPageHistory(path, {
repository: { url: 'https://github.com/owner/repository' },
});
return <GitChangelog commits={commits} />;
}Place it where history should appear. path is relative to the Git root, e.g. content/docs/guide.mdx, not a URL or slug. Reader options are listed in Configuration; standalone readers use the current working directory to discover Git when repository.directory is omitted.
Without Git at runtime, save the records as JSON during your build and import that snapshot. Git requires a complete checkout; failed commands and shallow checkouts report errors.
Reuse a reader
Each readPageHistory() call reads fresh repository metadata. A build processing multiple files can share a reader:
import { createHistoryReader } from 'fumadocs-page-history/git';
const history = createHistoryReader({ repository: { url: 'https://github.com/owner/repository' } });
const commits = await history.read('content/docs/guide.mdx');Create a new reader for each build. The compiler plugins manage this themselves.
Components
GitChangelog accepts commits, optional additional authors, and the display props. Pass repository: { url } when manually supplied records lack repositoryUrl.
For contributors only:
import { GitContributors } from 'fumadocs-page-history/ui';
<GitContributors commits={commits} authors={authors} />;resolveAuthors(names, authorMappings) from the Git entry point resolves additional authors. shouldShowChangelog(frontmatter) and shouldShowContributors(frontmatter) from fumadocs-page-history apply the same per-page controls as the plugins.