Display & language
Change how the history looks, translate its labels, and format dates.
This page covers the display options and how to show the sections in Chinese or another language. You can try most options in the demo first.
Display options
Set these under display in the plugin options, or pass them as props if you render GitChangelog yourself:
const display = {
locale: 'zh-CN',
defaultExpanded: true,
commitsRelativeTime: true,
};| Option | Default | Description |
|---|---|---|
locale | en | Language for dates and contributor names. |
defaultExpanded | false | Open the commit list when the page loads. |
commitsRelativeTime | false | Show commits from the past week as "2 days ago" instead of a date. |
showContributors | true | Show the contributors section. |
hideChangelogHeader, hideContributorsHeader | false | Hide a section heading, which also removes it from On this page. |
hideChangelogNoChangesText | false | Hide the "No history yet." message when you render the UI yourself. |
hideSortBy | false | Hide the sort button. |
displayAuthorsInsideCommitLine | false | Show author avatars on each commit. |
numCommitHashLetters | 7 | Length of the short commit hash. |
id, contributorsId | Automatic | Anchor IDs for the two sections. |
className | — | Extra classes for the wrapper. |
locale affects only dates and contributor names. Labels such as "Page history" and "Last edited" come from your site's translations. Set them up as shown in Single-language site.
- The section headings appear in On this page, with anchors that don't clash with your own headings. If you render more than one instance on a page, give each an
id. Its contributors section then uses<id>-contributors. - With
commitsRelativeTime, commits older than a week still show a date, so you can tell them apart. The "Last edited" summary is always relative. - On screens 640px wide or narrower, the commit icon is hidden to save space. The hash stays visible because it links to the commit.
Single-language site
To show the sections in Chinese, start by setting display.locale:
import { defineConfig } from 'fumadocs-mdx/config';
import { remarkGitChangelog } from 'fumadocs-page-history/remark';
export default defineConfig({
mdxOptions: {
remarkPlugins: [
[
remarkGitChangelog,
{
repository: { url: 'https://github.com/owner/repository' },
display: { locale: 'zh-CN' },
},
],
],
},
});Then add Page History's labels to your translations. gitChangelogTranslations() registers the label keys, and zhCN() supplies the Chinese text. Rename it on import, here to historyZhCN, so it doesn't clash with presets from other packages:
import { defineTranslations } from 'fumadocs-core/i18n';
import { uiTranslations } from 'fumadocs-ui/i18n';
import { gitChangelogTranslations, zhCN as historyZhCN } from 'fumadocs-page-history/i18n';
export const translations = defineTranslations()
.extend(uiTranslations())
.extend(gitChangelogTranslations())
.preset(historyZhCN());Keep any translations and presets you already have in this chain. historyZhCN() covers only Page History's own labels.
Finally, pass the translations to your root provider:
import { RootProvider } from 'fumadocs-ui/provider/next';
import { i18nProvider } from 'fumadocs-ui/i18n';
import { translations } from '@/lib/translations';
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="zh-CN" suppressHydrationWarning>
<body>
<RootProvider i18n={i18nProvider(translations)}>{children}</RootProvider>
</body>
</html>
);
}Multi-language site
If your site already uses Fumadocs i18n, add the label keys and a preset for each language:
const translations = i18n
.translations()
.extend(uiTranslations())
.extend(gitChangelogTranslations())
.preset('zh', historyZhCN());Here zh is the language key from your i18n configuration. Pass the current language when you create the provider. Then register the plugin in each language's collection, with the matching display.locale such as en or zh-CN.
If you render GitChangelog yourself, pass the current page's locale. The demo shows both English and Chinese.
Time zones
Dates appear in each reader's own time zone, detected by the browser, so there is nothing to configure. The server can't know that time zone, so it renders dates in UTC, and the page switches them once it loads. Relative dates such as "yesterday" stay hidden until then. A date shown as a calendar date can move by one day if the commit was made near midnight.