Skip to content

Commit 2fcfe1c

Browse files
refactor: simplify mapContributors configuration (#210)
* refactor: simplify mapContributors configuration Signed-off-by: Neko Ayaka <neko@ayaka.moe> * 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 <neko@ayaka.moe> Co-authored-by: Northword <44738481+northword@users.noreply.github.com>
1 parent ad9ded3 commit 2fcfe1c

14 files changed

Lines changed: 563 additions & 152 deletions

File tree

cspell.config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ words:
99
- Astro
1010
- Attributify
1111
- avatar
12+
- ayaka
1213
- Baloo
1314
- baloo-2
1415
- blurhash
@@ -26,11 +27,13 @@ words:
2627
- evanw
2728
- execa
2829
- frontmatter
30+
- Gitea
2931
- graymatter
3032
- iconify
3133
- Logseq
3234
- mkdist
3335
- napi
36+
- neko
3437
- Nisekoi5
3538
- nodir
3639
- nolebase
@@ -41,6 +44,7 @@ words:
4144
- quotepath
4245
- Rehype
4346
- resvg
47+
- rizumu
4448
- Roboto
4549
- shikijs
4650
- thumbhash

docs/.vitepress/theme/index.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h } from 'vue'
1+
import { type Plugin, h } from 'vue'
22

33
import { MotionPlugin } from '@vueuse/motion'
44
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
@@ -45,8 +45,9 @@ export default defineThemeUnconfig({
4545
app.component('IntegrationCard', IntegrationCard)
4646
app.component('HomeContent', HomeContent)
4747
app.component('ThumbhashPreview', ThumbhashPreview)
48-
app.use(TwoslashFloatingVue)
49-
app.use(MotionPlugin)
48+
49+
app.use(TwoslashFloatingVue as Plugin)
50+
app.use(MotionPlugin as Plugin)
5051
},
5152
pluginPresets: [
5253
NolebasePluginPreset({
@@ -56,20 +57,23 @@ export default defineThemeUnconfig({
5657
mapContributors: [
5758
{
5859
name: 'Neko',
59-
avatar: 'https://github.com/nekomeowww.png',
60-
nameAliases: ['Neko Ayaka', 'Ayaka Neko'],
61-
emailAliases: ['neko@ayaka.moe'],
60+
username: 'nekomeowww',
61+
mapByNameAliases: ['Neko Ayaka', 'Ayaka Neko'],
62+
mapByEmailAliases: ['neko@ayaka.moe'],
6263
},
6364
{
6465
name: 'Rizumu',
65-
avatar: 'https://github.com/LittleSound.png',
66-
nameAliases: ['Rizumu Ayaka', 'Ayaka Rizumu'],
67-
emailAliases: ['rizumu@ayaka.moe'],
66+
username: 'LittleSound',
67+
mapByNameAliases: ['Rizumu Ayaka', 'Ayaka Rizumu'],
68+
mapByEmailAliases: ['rizumu@ayaka.moe'],
6869
},
6970
{
7071
name: 'Nisekoi5',
71-
avatar: 'https://github.com/Nisekoi5.png',
72-
nameAliases: ['Nisekoi5'],
72+
username: 'Nisekoi5',
73+
},
74+
{
75+
name: 'Northword',
76+
username: 'northword',
7377
},
7478
],
7579
},

docs/pages/en/integrations/vitepress-plugin-enhanced-mark/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ import packageJSON from '~/packages/vitepress-plugin-enhanced-mark/package.json'
66

77
As an interesting little plugin, it adds a <mark>sliding animation</mark> to your `<mark>` highlighted elements.
88

9+
::: info 🤔 Performance drop? No!
10+
11+
This plugin doesn't contain any JavaScript code, only one stylesheet is provided.
12+
13+
Therefore, it should be theoretically performant, and won't cause any page lag.
14+
15+
:::
16+
917
## Features
1018

1119
<div grid="~ cols-[auto_1fr] gap-1" items-start my-1>
@@ -21,14 +29,6 @@ As an interesting little plugin, it adds a <mark>sliding animation</mark> to you
2129
<span>Natively compatible with VitePress design</span>
2230
</div>
2331

24-
::: info 🤔 Performance drop? No!
25-
26-
This plugin doesn't contain any JavaScript code, only one stylesheet is provided.
27-
28-
Therefore, it should be theoretically performant, and won't cause any page lag.
29-
30-
:::
31-
3232
## Take a look
3333

3434
It works like this:

docs/pages/en/integrations/vitepress-plugin-git-changelog/configure-ui.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ export const Theme: ThemeConfig = {
6767
}
6868
```
6969

70-
### Option `mapContributors` - Map contributors' information
70+
### Option `mapAuthors` - Map contributors' information
7171

72-
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.
72+
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.
7373

7474
Let's say we have these logs:
7575

@@ -89,7 +89,7 @@ Author: John Doe <john.doe@anothersite.com>
8989
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.
9090
Such case happens when you changed your name or email address in the past.
9191

92-
To solve this, you can provide the `mapContributors` field in the configuration options to map the contributors' information:
92+
To solve this, you can provide the `mapAuthors` field in the configuration options to map the contributors' information:
9393

9494
```typescript twoslash
9595
import type { Theme as ThemeConfig } from 'vitepress'
@@ -106,11 +106,11 @@ export const Theme: ThemeConfig = {
106106
// Rest of the code...
107107

108108
app.provide(InjectionKey, { // [!code focus]
109-
mapContributors: [ // [!code focus]
109+
mapAuthors: [ // [!code focus]
110110
{ // [!code focus]
111111
name: 'John Doe', // [!code focus]
112-
email: 'john.doe@example.com', // [!code focus]
113-
emailAliases: ['john.doe@anothersite.com'] // [!code focus]
112+
username: 'john_doe', // [!code focus]
113+
mapByEmailAliases: ['john.doe@anothersite.com'] // [!code focus]
114114
} // [!code focus]
115115
] // [!code focus]
116116
}) // [!code focus]
@@ -194,35 +194,35 @@ export interface Options {
194194
* ```
195195
*/
196196
locales?: Record<string, Locale>
197-
mapContributors?: Array<{
197+
mapAuthors?: Array<{
198198
/**
199199
* The overriding display name of the contributor
200200
*/
201201
name?: string
202202
/**
203-
* The overriding avatar of the contributor
203+
* The overriding GitHub, GitLab, Gitea username of the contributor
204204
*/
205-
avatar?: string
205+
username?: string
206206
/**
207-
* The overriding email of the contributor
207+
* The overriding avatar of the contributor
208208
*/
209-
email?: string
209+
avatar?: string
210210
/**
211211
* Whether to add a link to the contributor's profile
212212
*/
213-
links?: SocialEntry[]
213+
links?: string | SocialEntry[]
214214
/**
215215
* More names to be recognized as the same contributor.
216216
*
217217
* Useful when you changed your name or email address in the past.
218218
*/
219-
nameAliases?: string[]
219+
mapByNameAliases?: string[]
220220
/**
221221
* More emails to be recognized as the same contributor.
222222
*
223223
* Useful when you changed your email address in the past.
224224
*/
225-
emailAliases?: string[]
225+
mapByEmailAliases?: string[]
226226
}>
227227
}
228228
```

docs/pages/en/releases/migrations/v1-to-v2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ import '@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css'
204204
205205
## Git-based page histories
206206
207+
### UI config
208+
209+
1. `mapContributors` now deprecated, please use `mapAuthors` instead since it's more neutral for writers.
210+
2. `nameAliases` now deprecated, please use `mapByNameAliases` instead, which is more clear and consistent with other plugins.
211+
3. `emailAliases` now deprecated, please use `mapByEmailAliases` instead, which is more clear and consistent with other plugins.
212+
4. Added new `username` field, which is the username of the author on GitHub used to fetch the avatar.
213+
214+
### `Vite` config
215+
207216
1. `includeDirs` and `includeExtensions` have been deprecated and merged into `include`, which is a list of glob modes with `!` negation.
208217
2. If a renderable page file located outside of the VitePress root (where `.vitepress` lives), please configure the `cwd` (current working directory) to the parent directory of the page files. (For example, in a Monorepo, if the source file that rendered a page s located outside of `docs/`, you need to set `cwd` to the root directory of the Monorepo instead of the root of VitePress.)
209218
3. No longer needed to configure `rewritePaths`, therefor `rewritePaths` is now deprecated, can be safely removed.

docs/pages/zh-CN/integrations/vitepress-plugin-enhanced-mark/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ import packageJSON from '~/packages/vitepress-plugin-enhanced-mark/package.json'
66

77
这是一个很有意思的小插件,为你的 `<mark>` 高亮元素添加<mark>展开划过</mark>的小动画。
88

9+
::: info 🤔 性能问题?完全不用担心!
10+
11+
该插件不包含任何 JavaScript 代码,只为 `<mark>` 元素提供动画样式。
12+
13+
因此,理论上它的性能应该很好,不会造成任何页面掉帧卡顿。
14+
15+
:::
16+
917
## 功能
1018

1119
<div grid="~ cols-[auto_1fr] gap-1" items-start my-1>
@@ -21,14 +29,6 @@ import packageJSON from '~/packages/vitepress-plugin-enhanced-mark/package.json'
2129
<span>原生与 VitePress 样式兼容</span>
2230
</div>
2331

24-
::: info 🤔 Performance drop? No!
25-
26-
This plugin doesn't contain any JavaScript code, only one stylesheet is provided.
27-
28-
Therefore, it should be theoretically performant, and won't cause any page lag.
29-
30-
:::
31-
3232
## 一览效果
3333

3434
它看起来将会是这样的:

docs/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-ui.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Author: John Doe <john.doe@anothersite.com>
8787
现在我们有两个来自同一个人的提交,只有电子邮件地址不同。在不进行任何配置的默认情况下,插件会将它们视为两个不同的贡献者。
8888
这种情况通常是因为你或者其他贡献者更改了自己的电子邮件地址。
8989

90-
要解决这个问题,我们可以使用 `mapContributors` 选项:
90+
要解决这个问题,我们可以使用 `mapAuthors` 选项:
9191

9292
```typescript twoslash
9393
import type { Theme as ThemeConfig } from 'vitepress'
@@ -104,11 +104,11 @@ export const Theme: ThemeConfig = {
104104
// Rest of the code...
105105

106106
app.provide(InjectionKey, { // [!code focus]
107-
mapContributors: [ // [!code focus]
107+
mapAuthors: [ // [!code focus]
108108
{ // [!code focus]
109109
name: 'John Doe', // [!code focus]
110-
email: 'john.doe@example.com', // [!code focus]
111-
emailAliases: ['john.doe@anothersite.com'] // [!code focus]
110+
username: 'john_doe', // [!code focus]
111+
mapByEmailAliases: ['john.doe@anothersite.com'] // [!code focus]
112112
} // [!code focus]
113113
] // [!code focus]
114114
}) // [!code focus]
@@ -192,35 +192,35 @@ export interface Options {
192192
* ```
193193
*/
194194
locales?: Record<string, Locale>
195-
mapContributors?: Array<{
195+
mapAuthors?: Array<{
196196
/**
197197
* The overriding display name of the contributor
198198
*/
199199
name?: string
200200
/**
201-
* The overriding avatar of the contributor
201+
* The overriding GitHub, GitLab, Gitea username of the contributor
202202
*/
203-
avatar?: string
203+
username?: string
204204
/**
205-
* The overriding email of the contributor
205+
* The overriding avatar of the contributor
206206
*/
207-
email?: string
207+
avatar?: string
208208
/**
209209
* Whether to add a link to the contributor's profile
210210
*/
211-
links?: SocialEntry[]
211+
links?: string | SocialEntry[]
212212
/**
213213
* More names to be recognized as the same contributor.
214214
*
215215
* Useful when you changed your name or email address in the past.
216216
*/
217-
nameAliases?: string[]
217+
mapByNameAliases?: string[]
218218
/**
219219
* More emails to be recognized as the same contributor.
220220
*
221221
* Useful when you changed your email address in the past.
222222
*/
223-
emailAliases?: string[]
223+
mapByEmailAliases?: string[]
224224
}>
225225
}
226226
```

docs/pages/zh-CN/releases/migrations/v1-to-v2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ import '@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css'
204204
205205
## 基于 Git 的页面历史
206206
207+
### UI 配置
208+
209+
1. `mapContributors` 现在已经被废弃,请使用对书写作者更为中立的 `mapAuthors`
210+
2. `nameAliases` 现在已经被废弃,请使用更清晰,并与其他插件保持一致的 `mapByNameAliases`
211+
3. `emailAliases` 现在已经被废弃,请使用更清晰,并与其他插件保持一致的 `mapByEmailAliases`
212+
4. 添加了新的 `username` 字段映射,以便更好地支持 GitHub 头像。
213+
214+
### `Vite` 配置
215+
207216
1.`includeDirs``includeExtensions` 已被弃用并合并到 `include` 中,配置时,可以使用带有 `!` 作为否定的 glob 匹配模式。
208217
2.如果最终会被渲染的文件所对应的页面文件位于 VitePress 根目录(即 `.vitepress`所在目录)之外,**请将 `cwd`(当前工作目录)配置为页面文件的父目录**。(例如,在 Monorepo 中,如果需要读取 `docs/` 以外的文件,则需要将 `cwd` 设置为 Monorepo 的根目录,而不是 VitePress 的根目录)。
209218
3.不再需要配置 `rewritePaths`,因此 `rewritePaths` 已被弃用,可以安全删除。

0 commit comments

Comments
 (0)