The document is only used for theme display, please go to the official site for the latest Vuepress documentation
git
This plugin will collect git information of your pages, including the created and updated time, the contributors, etc.
The lastUpdated and contributors of default theme is powered by this plugin.
This plugin is mainly used to develop themes. You won't need to use it directly in most cases.
Git Repository
This plugin requires your project to be inside a Git Repositoryopen in new window, so that it can collect information from the commit history.
You should ensure all commits are available when building your site. For example, CI workflows usually clone your repository with --depth 1open in new window to avoid fetching all commits, so you should disable the behavior to make this plugin work properly in CI.
WARNING
This plugin will significantly slow down the speed of data preparation, especially when you have a lot of pages. You can consider disabling this plugin in dev
mode to get better development experience.
Options
createdTime
Type:
boolean
Default:
true
Details:
Whether to collect page created time or not.
updatedTime
Type:
boolean
Default:
true
Details:
Whether to collect page updated time or not.
contributors
Type:
boolean
Default:
true
Details:
Whether to collect page contributors or not.
Page Data
This plugin will add a git
field to page data.
After using this plugin, you can get the collected git information in page data:
import { usePageData } from '@vuepress/client'
import type { GitPluginPageData } from '@vuepress/client'
export default {
setup() {
const page = usePageData<GitPluginPageData>()
console.log(page.value.git)
}
}
2
3
4
5
6
7
8
9
git.createdTime
Type:
number
Details:
Unix timestamp in milliseconds of the first commit of the page.
git.updatedTime
Type:
number
Details:
Unix timestamp in milliseconds of the last commit of the page.
git.contributors
- Type:
GitContributor[]
interface GitContributor {
name: string
email: string
commits: number
}
2
3
4
5
Details:
The contributors information of the page.