-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: mv data processing to vite side (#269)
* refactor!: mv data processing to vite side * fix: build error, clean code, tweaks * test: complate test cases * docs: refresh docs * docs: add missed pages * fix: types error * refactor: mv hmr logic to composable * style: fix lint * docs: add v2->v3 to nav and sidebar
- Loading branch information
Showing
29 changed files
with
1,182 additions
and
1,074 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,28 +54,6 @@ export default defineThemeUnconfig({ | |
gitChangelog: { | ||
enable: true, | ||
options: { | ||
mapContributors: [ | ||
{ | ||
name: 'Neko', | ||
username: 'nekomeowww', | ||
mapByNameAliases: ['Neko Ayaka', 'Ayaka Neko'], | ||
mapByEmailAliases: ['[email protected]'], | ||
}, | ||
{ | ||
name: 'Rizumu', | ||
username: 'LittleSound', | ||
mapByNameAliases: ['Rizumu Ayaka', 'Ayaka Rizumu'], | ||
mapByEmailAliases: ['[email protected]'], | ||
}, | ||
{ | ||
name: 'Nisekoi5', | ||
username: 'Nisekoi5', | ||
}, | ||
{ | ||
name: 'Northword', | ||
username: 'northword', | ||
}, | ||
], | ||
commitsRelativeTime: true, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
# Configuration | ||
|
||
The Git-based page histories plugin currently provides configuration options related to **Internationalization** and **Contributors** section. | ||
::: danger Deprecating the `mapAuthors` field for UI component options | ||
|
||
We migrated the `mapAuthors` configuration to [configure Vite plugins](./configure-vite-plugins#option-mapauthors---map-contributors-information). | ||
|
||
For specific migration information, see [Migrating from v2 to v3](/pages/en/releases/migrations/v2-to-v3). | ||
|
||
::: | ||
|
||
The Git-based page histories plugin currently provides configuration options related to **Internationalization** and **UI** section. | ||
|
||
## Configure in VitePress | ||
|
||
|
@@ -67,59 +75,6 @@ export const Theme: ThemeConfig = { | |
} | ||
``` | ||
|
||
### Option `mapAuthors` - Map contributors' information | ||
|
||
The `mapAuthors` field in the configuration options is used to map the contributors' information. You can provide the `mapAuthors` field in the configuration options to map the contributors' information, including the display name, avatar, email, social links, and aliases. | ||
|
||
Let's say we have these logs: | ||
|
||
```plaintext | ||
commit 1 | ||
Author: John Doe <[email protected]> | ||
Date: Fri Oct 1 12:00:00 2021 +0800 | ||
Add a new feature | ||
commit 2 | ||
Author: John Doe <[email protected]> | ||
Fix a bug | ||
``` | ||
|
||
We now have two commits from the same person, with only the email address is different. By default, the plugin will treat them as two different contributors. | ||
Such case happens when you changed your name or email address in the past. | ||
|
||
To solve this, you can provide the `mapAuthors` field in the configuration options to map the contributors' information: | ||
|
||
```typescript twoslash | ||
import type { Theme as ThemeConfig } from 'vitepress' | ||
import DefaultTheme from 'vitepress/theme' | ||
|
||
import { InjectionKey } from '@nolebase/vitepress-plugin-git-changelog/client' // [!code focus] | ||
export const Theme: ThemeConfig = { | ||
extends: DefaultTheme, | ||
Layout: () => { | ||
// Rest of the code... | ||
}, | ||
enhanceApp({ app }) { | ||
// Rest of the code... | ||
|
||
app.provide(InjectionKey, { // [!code focus] | ||
mapAuthors: [ // [!code focus] | ||
{ // [!code focus] | ||
name: 'John Doe', // [!code focus] | ||
username: 'john_doe', // [!code focus] | ||
mapByEmailAliases: ['[email protected]'] // [!code focus] | ||
} // [!code focus] | ||
] // [!code focus] | ||
}) // [!code focus] | ||
|
||
// Rest of the code... | ||
}, | ||
} | ||
``` | ||
|
||
## Options inside | ||
|
||
::: warning Deprecating warning | ||
|
@@ -224,36 +179,6 @@ export interface Options { | |
* ``` | ||
*/ | ||
locales?: Record<string, Locale> | ||
mapAuthors?: Array<{ | ||
/** | ||
* The overriding display name of the contributor | ||
*/ | ||
name?: string | ||
/** | ||
* The overriding GitHub, GitLab, Gitea username of the contributor | ||
*/ | ||
username?: string | ||
/** | ||
* The overriding avatar of the contributor | ||
*/ | ||
avatar?: string | ||
/** | ||
* Whether to add a link to the contributor's profile | ||
*/ | ||
links?: string | SocialEntry[] | ||
/** | ||
* More names to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your name or email address in the past. | ||
*/ | ||
mapByNameAliases?: string[] | ||
/** | ||
* More emails to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your email address in the past. | ||
*/ | ||
mapByEmailAliases?: string[] | ||
}> | ||
/** | ||
* Number of commit hash letters to display | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,9 @@ For information, please refer to [Migrate from v1 to v2](/pages/en/releases/migr | |
|
||
Besides the UI widget components, Git-based page histories offer another two Vite plugins for data fetching and rendering. These plugins are `GitChangelog` and `GitChangelogMarkdownSection`. | ||
|
||
### Configure Vite plugins | ||
|
||
<!--@include: @/pages/en/snippets/configure-tsconfig.md--> | ||
|
||
#### `GitChangelog` plugin | ||
## Configure `GitChangelog` plugin | ||
|
||
Remember this part back at the time where we first introduced the `GitChangelog` plugin? | ||
|
||
|
@@ -42,16 +40,74 @@ export default defineConfig(() => { | |
|
||
In the `GitChangelog` plugin, you can configure the `repoURL` option to point to your repository URL. This is the only required option for the plugin to work properly. | ||
|
||
### Option `mapAuthors` - Map contributors' information | ||
|
||
The `mapAuthors` field in the configuration options is used to map the contributors' information. You can provide the `mapAuthors` field in the configuration options to map the contributors' information, including the display name, avatar, email, social links, and aliases. | ||
|
||
Let's say we have these logs: | ||
|
||
```plaintext | ||
commit 1 | ||
Author: John Doe <[email protected]> | ||
Date: Fri Oct 1 12:00:00 2021 +0800 | ||
Add a new feature | ||
commit 2 | ||
Author: John Doe <[email protected]> | ||
Fix a bug | ||
``` | ||
|
||
We now have two commits from the same person, with only the email address is different. By default, the plugin will treat them as two different contributors. | ||
Such case happens when you changed your name or email address in the past. | ||
|
||
To solve this, you can provide the `mapAuthors` field in the configuration options to map the contributors' information: | ||
|
||
```typescript twoslash | ||
import { join } from 'node:path' | ||
import { defineConfig } from 'vite' | ||
import { | ||
GitChangelog, | ||
GitChangelogMarkdownSection, | ||
} from '@nolebase/vitepress-plugin-git-changelog/vite' | ||
|
||
export default defineConfig(() => { | ||
return { | ||
plugins: [ | ||
GitChangelog({ // [!code focus] | ||
// Fill in your repository URL here | ||
repoURL: () => 'https://github.com/nolebase/integrations', | ||
mapAuthors: [ // [!code focus] | ||
{ // [!code focus] | ||
name: 'John Doe', // [!code focus] | ||
username: 'john_doe', // [!code focus] | ||
mapByEmailAliases: ['[email protected]'] // [!code focus] | ||
} // [!code focus] | ||
] // [!code focus] | ||
}), // [!code focus] | ||
GitChangelogMarkdownSection(), | ||
] | ||
// other vite configurations... | ||
} | ||
}) | ||
``` | ||
|
||
### All options | ||
|
||
But the options don't stop there. We have more options to configure the plugin to fit your needs. | ||
|
||
::: details Full list of options | ||
|
||
```typescript twoslash | ||
import type { | ||
Commit, CommitToStringHandler, CommitToStringsHandler, RewritePathsBy | ||
Author, | ||
CommitToStringHandler, | ||
CommitToStringsHandler, | ||
RewritePathsBy | ||
} from '@nolebase/vitepress-plugin-git-changelog/vite' | ||
// ---cut--- | ||
interface Options { | ||
interface GitChangelogOptions { | ||
/** | ||
* The current working directory in which to search files. | ||
* | ||
|
@@ -64,6 +120,10 @@ interface Options { | |
* @default ['** /*.md', '!node_modules'] | ||
*/ | ||
include?: string[] | ||
/** | ||
* Map authors | ||
*/ | ||
mapAuthors?: Author[] | ||
/** | ||
* Your repository URL. | ||
* Yes, you can dynamically generate it. | ||
|
@@ -144,7 +204,7 @@ interface Options { | |
|
||
::: | ||
|
||
#### `GitChangelogMarkdownSection` plugin | ||
## Configure `GitChangelogMarkdownSection` plugin | ||
|
||
The `GitChangelogMarkdownSection` plugin is a plugin that helps you to inject the Markdown sections into your VitePress pages. It's a plugin that works with the `GitChangelog` plugin to provide the data for the Markdown sections. | ||
|
||
|
@@ -205,7 +265,7 @@ interface GitChangelogMarkdownSectionOptions { | |
|
||
::: | ||
|
||
#### Excluding a page from the transformation of `GitChangelogMarkdownSection` | ||
### Excluding a page from the transformation of `GitChangelogMarkdownSection` | ||
|
||
You can exclude a page from the transformation of `GitChangelogMarkdownSection` by adding the `nolebase.gitChangelog` or `gitChangelog` frontmatter to the page: | ||
|
||
|
@@ -224,7 +284,7 @@ gitChangelog: false | |
--- | ||
``` | ||
|
||
#### Globally exclude a page from the transformation of `GitChangelogMarkdownSection` | ||
### Globally exclude a page from the transformation of `GitChangelogMarkdownSection` | ||
|
||
You can globally exclude a page from the transformation of `GitChangelogMarkdownSection` by configuring the `exclude` option: | ||
|
||
|
@@ -244,7 +304,7 @@ export default defineConfig({ | |
}) | ||
``` | ||
|
||
#### Globally disable the changelog or contributors section | ||
### Globally disable the changelog or contributors section | ||
|
||
You can globally disable the changelog or contributors section by configuring the `sections` option: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Migrating from `v2` to `v3 | ||
|
||
## Git-based page history | ||
|
||
### UI configuration | ||
|
||
- `mapAuthors` is deprecated, please configure this option in the Vite plugin. |
Oops, something went wrong.