2024-11-09 00:35:28 +08:00

2.9 KiB
Raw Blame History

title, icon, badge, createTime, permalink
title icon badge createTime permalink
文章变更历史 radix-icons:activity-log
type text
tip v1.0.0-rc.115 +
2024/11/07 18:16:25 /guide/features/changelog/

概述

主题支持为文章添加 文章变更历史,以便更好的了解您的文章修改历史。

文章变更历史 通过 git 提交记录获取。

该功能由 @vuepress/plugin-git 提供支持。

使用

主题已内置 @vuepress/plugin-git 插件,你无需重新安装即可使用。

在主题配置文件中启用该功能:

::: code-tabs @tab .vuepress/config.ts

import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'

export default defineUserConfig({
  theme: plumeTheme({
    // 默认 不启用,仅当 plugins.git 为 true 时生效
    // 此配置在 plume.config.ts 中无效
    changelog: true,

    plugins: {
      // 如果您在此处直接声明为 true则表示开发环境和生产环境都启用该功能
      git: process.env.NODE_ENV === 'production'
    }
  })
})

:::

::: warning 出于性能考虑,主题默认不会在 开发环境中启用该功能,仅在 生产环境中启用。 :::

配置

interface ChangelogOptions {
  /**
   * 最大变更记录条数, 默认获取所有记录
   */
  maxCount?: number
  /**
   * git 仓库的访问地址例如https://github.com/vuepress/ecosystem
   */
  repoUrl?: string
  /**
   * 提交记录访问地址模式
   *
   * - `:repo` - git 仓库的访问地址
   * - `:hash` - 提交记录的 hash
   *
   * @default ':repo/commit/:hash'
   */
  commitUrlPattern?: string
  /**
   * issue 访问地址模式
   *
   * - `:repo` - git 仓库的访问地址
   * - `:issue` - issue 的 id
   *
   * @default ':repo/issues/:issue'
   */
  issueUrlPattern?: string
  /**
   * tag 访问地址模式,
   * 默认值:':repo/releases/tag/:tag'
   *
   * - `:repo` - git 仓库的访问地址
   * - `:tag` - tag 的名称
   *
   * @default ':repo/releases/tag/:tag'
   */
  tagUrlPattern?: string
}
import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'

export default defineUserConfig({
  theme: plumeTheme({
    changelog: {
      maxCount: 10,
      repoUrl: 'https://github.com/vuepress/vuepress',
      commitUrlPattern: ':repo/commit/:hash',
      issueUrlPattern: ':repo/issues/:issue',
      tagUrlPattern: ':repo/releases/tag/:tag'
    },

  })
})

::: warning 注意 请确保 changelog.repoUrl 配置正确, 默认值为 docsRepo

主题默认适配了 github/gitlab/gitee/bitbucket git 托管服务的相关访问地址模式。 如果您使用的是内建的托管服务或者其他,请自行配置 commitUrlPatternissueUrlPatterntagUrlPattern。 :::