-
-
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: simplify
mapContributors
configuration (#210)
* refactor: simplify mapContributors configuration Signed-off-by: Neko Ayaka <[email protected]> * fix(git-changelog): mapAuthors.name also include in nameAlias, default return github link when no links but with username (#211) * fix: support mapAuthor.name to nameAlias > When searching for nameAlisa, consider mapAuthors.name as one of its name Alias at the same time, which will prevent the user from typing name and nameAlisa repeatedly in mapAuthor. * fix: should return github link when without links and with username * fix: modify mapContributors config accordingly --------- Signed-off-by: Neko Ayaka <[email protected]> Co-authored-by: Northword <[email protected]>
- Loading branch information
1 parent
ad9ded3
commit 2fcfe1c
Showing
14 changed files
with
563 additions
and
152 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { h } from 'vue' | ||
import { type Plugin, h } from 'vue' | ||
|
||
import { MotionPlugin } from '@vueuse/motion' | ||
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client' | ||
|
@@ -45,8 +45,9 @@ export default defineThemeUnconfig({ | |
app.component('IntegrationCard', IntegrationCard) | ||
app.component('HomeContent', HomeContent) | ||
app.component('ThumbhashPreview', ThumbhashPreview) | ||
app.use(TwoslashFloatingVue) | ||
app.use(MotionPlugin) | ||
|
||
app.use(TwoslashFloatingVue as Plugin) | ||
app.use(MotionPlugin as Plugin) | ||
}, | ||
pluginPresets: [ | ||
NolebasePluginPreset({ | ||
|
@@ -56,20 +57,23 @@ export default defineThemeUnconfig({ | |
mapContributors: [ | ||
{ | ||
name: 'Neko', | ||
avatar: 'https://github.com/nekomeowww.png', | ||
nameAliases: ['Neko Ayaka', 'Ayaka Neko'], | ||
emailAliases: ['[email protected]'], | ||
username: 'nekomeowww', | ||
mapByNameAliases: ['Neko Ayaka', 'Ayaka Neko'], | ||
mapByEmailAliases: ['[email protected]'], | ||
}, | ||
{ | ||
name: 'Rizumu', | ||
avatar: 'https://github.com/LittleSound.png', | ||
nameAliases: ['Rizumu Ayaka', 'Ayaka Rizumu'], | ||
emailAliases: ['[email protected]'], | ||
username: 'LittleSound', | ||
mapByNameAliases: ['Rizumu Ayaka', 'Ayaka Rizumu'], | ||
mapByEmailAliases: ['[email protected]'], | ||
}, | ||
{ | ||
name: 'Nisekoi5', | ||
avatar: 'https://github.com/Nisekoi5.png', | ||
nameAliases: ['Nisekoi5'], | ||
username: 'Nisekoi5', | ||
}, | ||
{ | ||
name: 'Northword', | ||
username: 'northword', | ||
}, | ||
], | ||
}, | ||
|
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 |
---|---|---|
|
@@ -67,9 +67,9 @@ export const Theme: ThemeConfig = { | |
} | ||
``` | ||
|
||
### Option `mapContributors` - Map contributors' information | ||
### Option `mapAuthors` - Map contributors' information | ||
|
||
The `mapContributors` field in the configuration options is used to map the contributors' information. You can provide the `mapContributors` field in the configuration options to map the contributors' information, including the display name, avatar, email, social links, and aliases. | ||
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: | ||
|
||
|
@@ -89,7 +89,7 @@ Author: John Doe <[email protected]> | |
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 `mapContributors` field in the configuration options to map the contributors' information: | ||
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' | ||
|
@@ -106,11 +106,11 @@ export const Theme: ThemeConfig = { | |
// Rest of the code... | ||
|
||
app.provide(InjectionKey, { // [!code focus] | ||
mapContributors: [ // [!code focus] | ||
mapAuthors: [ // [!code focus] | ||
{ // [!code focus] | ||
name: 'John Doe', // [!code focus] | ||
email: '[email protected]', // [!code focus] | ||
emailAliases: ['[email protected]'] // [!code focus] | ||
username: 'john_doe', // [!code focus] | ||
mapByEmailAliases: ['[email protected]'] // [!code focus] | ||
} // [!code focus] | ||
] // [!code focus] | ||
}) // [!code focus] | ||
|
@@ -194,35 +194,35 @@ export interface Options { | |
* ``` | ||
*/ | ||
locales?: Record<string, Locale> | ||
mapContributors?: Array<{ | ||
mapAuthors?: Array<{ | ||
/** | ||
* The overriding display name of the contributor | ||
*/ | ||
name?: string | ||
/** | ||
* The overriding avatar of the contributor | ||
* The overriding GitHub, GitLab, Gitea username of the contributor | ||
*/ | ||
avatar?: string | ||
username?: string | ||
/** | ||
* The overriding email of the contributor | ||
* The overriding avatar of the contributor | ||
*/ | ||
email?: string | ||
avatar?: string | ||
/** | ||
* Whether to add a link to the contributor's profile | ||
*/ | ||
links?: SocialEntry[] | ||
links?: string | SocialEntry[] | ||
/** | ||
* More names to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your name or email address in the past. | ||
*/ | ||
nameAliases?: string[] | ||
mapByNameAliases?: string[] | ||
/** | ||
* More emails to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your email address in the past. | ||
*/ | ||
emailAliases?: string[] | ||
mapByEmailAliases?: string[] | ||
}> | ||
} | ||
``` | ||
|
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
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 |
---|---|---|
|
@@ -87,7 +87,7 @@ Author: John Doe <[email protected]> | |
现在我们有两个来自同一个人的提交,只有电子邮件地址不同。在不进行任何配置的默认情况下,插件会将它们视为两个不同的贡献者。 | ||
这种情况通常是因为你或者其他贡献者更改了自己的电子邮件地址。 | ||
|
||
要解决这个问题,我们可以使用 `mapContributors` 选项: | ||
要解决这个问题,我们可以使用 `mapAuthors` 选项: | ||
|
||
```typescript twoslash | ||
import type { Theme as ThemeConfig } from 'vitepress' | ||
|
@@ -104,11 +104,11 @@ export const Theme: ThemeConfig = { | |
// Rest of the code... | ||
|
||
app.provide(InjectionKey, { // [!code focus] | ||
mapContributors: [ // [!code focus] | ||
mapAuthors: [ // [!code focus] | ||
{ // [!code focus] | ||
name: 'John Doe', // [!code focus] | ||
email: '[email protected]', // [!code focus] | ||
emailAliases: ['[email protected]'] // [!code focus] | ||
username: 'john_doe', // [!code focus] | ||
mapByEmailAliases: ['[email protected]'] // [!code focus] | ||
} // [!code focus] | ||
] // [!code focus] | ||
}) // [!code focus] | ||
|
@@ -192,35 +192,35 @@ export interface Options { | |
* ``` | ||
*/ | ||
locales?: Record<string, Locale> | ||
mapContributors?: Array<{ | ||
mapAuthors?: Array<{ | ||
/** | ||
* The overriding display name of the contributor | ||
*/ | ||
name?: string | ||
/** | ||
* The overriding avatar of the contributor | ||
* The overriding GitHub, GitLab, Gitea username of the contributor | ||
*/ | ||
avatar?: string | ||
username?: string | ||
/** | ||
* The overriding email of the contributor | ||
* The overriding avatar of the contributor | ||
*/ | ||
email?: string | ||
avatar?: string | ||
/** | ||
* Whether to add a link to the contributor's profile | ||
*/ | ||
links?: SocialEntry[] | ||
links?: string | SocialEntry[] | ||
/** | ||
* More names to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your name or email address in the past. | ||
*/ | ||
nameAliases?: string[] | ||
mapByNameAliases?: string[] | ||
/** | ||
* More emails to be recognized as the same contributor. | ||
* | ||
* Useful when you changed your email address in the past. | ||
*/ | ||
emailAliases?: string[] | ||
mapByEmailAliases?: string[] | ||
}> | ||
} | ||
``` | ||
|
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
Oops, something went wrong.