---
title: "CommitChangelog"
description: "Use `:commit-changelog` to display GitHub commits for a component or file, grouped by release."
canonical_url: "https://docs.mhaibaraai.me/en/docs/components/commit-changelog"
---
# CommitChangelog

> Use \`:commit-changelog\` to display GitHub commits for a component or file, grouped by release.

`CommitChangelog` requests the GitHub commits of a file path and groups them by release: released commits go under their version, unreleased ones under `Soon`. When the site has a [releases page](https://docs.mhaibaraai.me/en/docs/guide/pages), version tags link to it; otherwise they open the GitHub release.

The component does not depend on the `componentDocs` flag; it only needs the GitHub integration.

## Prerequisites

- **Repository**: `github.owner`, `github.name`, `github.url` and `github.branch` are inferred from the local git remote. Set them in `app/app.config.ts` when inference fails, see the [app.config reference](https://docs.mhaibaraai.me/en/docs/reference/app-config)
- **Access token**: set `NUXT_GITHUB_TOKEN` in the environment

```bash [.env]
NUXT_GITHUB_TOKEN=<your-github-token>
```

> [!WARNING]
> See: https://github.com/settings/tokens
> 
> The token must be able to read commits: a read-only fine-grained token works for public repositories, private repositories need Contents read access.

> [!TIP]
> 
> Without a token, or with 
> 
> github: false
> 
> , the component shows 
> 
> No recent changes
> 
>  and the build does not fail.

## Usage

### Inferred file path

```mdc
:commit-changelog
```

The path is built as `{commitPath}/{prefix}/{name}.{suffix}`:

| Part | Source |
| --- | --- |
| `commitPath` | The component's `commitPath`, then `github.commitPath`, defaults to `src` |
| `prefix` | The component's `prefix`, empty by default |
| `name` | The component's `name`, defaults to the last segment of the current route |
| `suffix` | The component's `suffix`, then `github.suffix`, defaults to `vue` |

`name` is converted according to `casing`: the default `auto` uses PascalCase for `.vue` files and camelCase for others; `kebab`, `camel` and `pascal` force that style. On `/docs/components/accordion`, for example, the line above resolves to `src/Accordion.vue`.

### A specific file

```mdc
:commit-changelog{name="useUser" suffix="ts" commitPath="src/composables"}
```

If all files use kebab-case, set it once in `app/app.config.ts` instead of on every component:

```ts [app/app.config.ts]
export default defineAppConfig({
  github: {
    commitPath: 'src/composables',
    suffix: 'ts',
    casing: 'kebab'
  }
})
```

### Multiple files

Each entry in `files` overrides the top-level fields (`commitPath`, `prefix`, `suffix`, `name`, `casing`); missing fields fall back to the top-level values. Commits from all files are merged, deduplicated and sorted newest first:

```mdc
::commit-changelog
---
commitPath: layer/app/composables
suffix: ts
files:
  - name: useHeader
  - name: useNavigation
---
::
```

### Filter by author

Pass a GitHub username or commit email to `author`:

```mdc
:commit-changelog{author="octocat"}
```

> [!TIP]
> 
> The range is controlled by 
> 
> github.since
> 
> , 
> 
> github.until
> 
>  and 
> 
> github.perPage
> 
> \: no date limit by default and at most 100 commits per file.

## AI and raw markdown

In `/raw/**.md` and the Markdown returned by MCP, the component is replaced with links to the GitHub commit history using the same path rules; without `name`, the page title is used.

## API

### Props

```ts
/**
 * Props for the CommitChangelog component
 */
interface CommitChangelogProps {
  /**
   * 仓库中的文件路径
   * @default 'src'
   */
  commitPath?: string | undefined;
  /**
   * 文件路径的前缀
   */
  prefix?: string | undefined;
  /**
   * 文件扩展名
   * @default 'vue'
   */
  suffix?: string | undefined;
  /**
   * 要获取更新日志的组件或文件名
   */
  name?: string | undefined;
  /**
   * 按作者筛选提交
   */
  author?: string | undefined;
  /**
   * 文件名的命名格式
   * - 'auto': Vue 文件使用 PascalCase，其他使用 camelCase（默认）
   * - 'kebab': 保持 kebab-case（如 use-user.ts）
   * - 'camel': 转换为 camelCase（如 useUser.ts）
   * - 'pascal': 转换为 PascalCase（如 UseUser.ts）
   * @default 'auto'
   */
  casing?: "auto" | "kebab" | "camel" | "pascal" | undefined;
  /**
   * 关联多个文件：每一项与顶层 props 合并后各自解析出一个文件路径，
   * 对应的提交记录会合并去重并按时间倒序展示
   */
  files?: CommitChangelogFile[] | undefined;
}
```

## Related

- [PageLastCommit](https://docs.mhaibaraai.me/en/docs/components/page-last-commit): shows the latest commit of the current page in the header

## Changelog

See commit history for [layer/app/components/content/CommitChangelog.vue](https://github.com/mhaibaraai/movk-nuxt-docs/commits/main/layer/app/components/content/CommitChangelog.vue).

---

- [GitHub](https://github.com/mhaibaraai/movk-nuxt-docs/blob/main/layer/app/components/content/CommitChangelog.vue)


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.me/sitemap.md) for all pages.
