CommitChangelog
Overview
Fetches the commit history of a specified file path from a GitHub repository and displays it as a timeline.
Prerequisites
- GitHub configuration: configure your GitHub information in
app/app.config.ts. See GitHub integration configuration for details. - Environment variable: configure your GitHub Token in the
.envfile:NUXT_GITHUB_TOKEN=ghp_your_personal_access_token_here
repo or public_repo scope). You can create a new token in GitHub Settings > Developer settings > Personal access tokens.NUXT_GITHUB_TOKEN is not configured, the component will not error; instead it displays "No recent changes".Usage
Basic usage
Use the following syntax in your Markdown documentation:
:commit-changelog
The component automatically infers the component name from the current page route and fetches the commit history of the corresponding file.
Displaying a Vue component's commit history
:commit-changelog{name="Accordion"}
Example output:
Displaying a TypeScript file's commit history
:commit-changelog{suffix="ts" name="useColorMode"}
Filtering commits by author
Add author to the URL query parameters to show only a specific author's commits:
:commit-changelog{author="user@example.com"}
author parameter can be a GitHub username or email address. For example: ?author=octocat or ?author=user@example.comFiles named in kebab-case
For composables or utils files named in kebab-case:
:commit-changelog{suffix="ts" name="use-user" casing="kebab" commitPath="composables"}
This looks for the commit history of composables/use-user.ts.
kebab-case, it is recommended to configure github.casing: 'kebab' globally in app/app.config.ts so you do not need to repeat it for every component.export default defineAppConfig({
github: {
casing: 'kebab', // Use kebab-case as the global default
// Other configuration...
}
})
Full configuration example
::commit-changelog
---
commitPath: 'packages/core/src'
prefix: 'components'
suffix: 'ts'
name: 'useUser'
author: 'user@example.com'
---
API
Props
| Prop | Default | Type |
|---|---|---|
name | string要获取更新日志的组件或文件名 | |
commitPath | 'src' | string仓库中的文件路径 |
prefix | string文件路径的前缀 | |
suffix | 'vue' | string文件扩展名 |
author | string按作者筛选提交 | |
casing | 'auto' | "auto" | "kebab" | "camel" | "pascal"文件名的命名格式
|
Related
- PageLastCommit — display the last update info for the current page
- useFetchComponentMeta — the composable for fetching component metadata
Changelog
ComponentCode
ComponentCode lets authors drive the live rendering of any registered Vue component from a declarative property matrix in Markdown, while synthesizing a copy-paste Vue snippet in sync.
PageLastCommit
PageLastCommit automatically displays the last update time, commit author, and commit message below a documentation page's title, with automatic author detection in PR squash-merge scenarios. Requires NUXT_GITHUB_TOKEN and github.rootDir, and supports custom date formats via Intl.DateTimeFormatOptions.