PageLastCommit

The meta row below the lead of every docs page shows the latest commit of its Markdown file, with time, author and message. This page covers when it appears, date formatting and author detection for PR squash merges.

PageLastCommit is already mounted in the meta row below the lead of every docs page, next to the source and copy page links; you never add it in Markdown. It shows:

  • Updated at: the time of the file's latest commit, formatted with github.dateFormat
  • Author: the committer's GitHub username and avatar, linking to their profile
  • Message: the first line of the commit message, linking to the commit

When it appears

Like CommitChangelog, it needs a working GitHub integration and NUXT_GITHUB_TOKEN:

.env
NUXT_GITHUB_TOKEN=<your-github-token>

The file path is {github.rootDir}/content/{page path}. Set rootDir when the docs site is not at the repository root:

app/app.config.ts
export default defineAppConfig({
  github: {
    rootDir: 'docs'
  }
})
With a wrong rootDir no commit is found and the component renders nothing. Set github: false to turn off the GitHub integration entirely.

Date format

github.dateFormat.locale and github.dateFormat.options are passed to Intl.DateTimeFormat. The layer defaults to zh-CN with year, month, day, hour and minute, in the server's time zone:

app/app.config.ts
export default defineAppConfig({
  github: {
    dateFormat: {
      locale: 'en-US',
      options: {
        dateStyle: 'medium',
        timeStyle: 'short',
        timeZone: 'Asia/Shanghai'
      }
    }
  }
})
Dates are formatted on the server. Prerendered sites show the build machine's time zone; set timeZone explicitly to pin it.
optionsOutput (en-US)
{ year: 'numeric', month: 'numeric', day: 'numeric' }10/23/2026
{ year: 'numeric', month: 'short', day: 'numeric' }Oct 23, 2026
{ dateStyle: 'medium', timeStyle: 'short' }Oct 23, 2026, 2:37 PM

PR squash merge

When a PR is merged on github.com, the committer is web-flow. The component detects this, parses the PR number from the message (such as #123), shows the PR author instead and links to the PR.

Customization

Props are passed in by the docs page, so showAvatar and showMessage cannot be set from Markdown. To hide the avatar or message, or restyle it, override the component with one of the same name in your project; PageLastCommit is not part of the override contract, so check it against the new implementation when upgrading.

API

Props

Prop Default Type
stem''string

文件路径(不含扩展名),通常由页面自动传入

extension'md'string

文件扩展名,通常由页面自动传入

showMessagetrueboolean

是否显示提交信息。

showAvatartrueboolean

是否显示作者头像。

Changelog

No recent changes
Copyright © 2024 - 2026