Skip to content

Commit fb31e25

Browse files
committed
chore: tweaks
1 parent 894c87b commit fb31e25

File tree

10 files changed

+127
-113
lines changed

10 files changed

+127
-113
lines changed

docs/plugins/development/git.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,27 +197,31 @@ This plugin will significantly slow down the speed of data preparation, especial
197197
- Type: `Record<string, GitLocaleData>`
198198

199199
```ts
200-
export interface GitLocaleData extends LocaleData {
200+
export interface GitLocaleData {
201201
/**
202202
* Contributors title
203203
*/
204204
contributors: string
205+
205206
/**
206207
* Changelog title
207208
*/
208209
changelog: string
210+
209211
/**
210-
* Changelog on time
212+
* Word to represent a commit "on" a time
211213
*/
212-
changelogOn: string
214+
timeOn: string
215+
213216
/**
214217
* Changelog button
215218
*/
216-
changelogButton: string
219+
viewChangelog: string
220+
217221
/**
218222
* Latest updated
219223
*/
220-
latestUpdated: string
224+
latestUpdateAt: string
221225
}
222226
```
223227

docs/zh/plugins/development/git.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default {
190190
- 类型: `Record<string, GitLocaleData>`
191191

192192
```ts
193-
export interface GitLocaleData extends LocaleData {
193+
export interface GitLocaleData {
194194
/**
195195
* 贡献者 标题
196196
*/
@@ -202,15 +202,15 @@ export default {
202202
/**
203203
* 更新 `于` 文本
204204
*/
205-
changelogOn: string
205+
timeOn: string
206206
/**
207207
* 查看更新日志 文本
208208
*/
209-
changelogButton: string
209+
viewChangelog: string
210210
/**
211211
* 最近更新 文本
212212
*/
213-
latestUpdated: string
213+
latestUpdateAt: string
214214
}
215215
```
216216

plugins/development/plugin-git/src/client/components/Changelog.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
GitPluginFrontmatter,
88
GitPluginPageData,
99
} from '../../shared/index.js'
10-
import { useGitLocales } from '../composables/index.js'
10+
import { useGitLocaleConfig } from '../composables/index.js'
1111
import { VPHeader } from './VPHeader.js'
1212

1313
import '../styles/vars.css'
@@ -17,25 +17,31 @@ type ResolvedChangelog = Omit<GitChangelog, 'date'> & { datetime: string }
1717

1818
export const Changelog = defineComponent({
1919
name: 'Changelog',
20+
2021
props: {
22+
/** Title of changelog */
23+
title: String,
24+
25+
/** header level of changelog */
2126
headerLevel: {
2227
type: Number,
2328
default: 2,
2429
},
25-
title: String,
2630
},
31+
2732
setup(props) {
33+
const locale = useGitLocaleConfig()
34+
const frontmatter = usePageFrontmatter<GitPluginFrontmatter>()
2835
const page = usePageData<GitPluginPageData>()
2936
const lang = usePageLang()
30-
const frontmatter = usePageFrontmatter<GitPluginFrontmatter>()
31-
const locale = useGitLocales()
3237

3338
const list = computed<ResolvedChangelog[]>(() => {
3439
if (frontmatter.value.changelog === false) return []
3540

3641
const formatter = new Intl.DateTimeFormat(lang.value, {
3742
dateStyle: 'short',
3843
})
44+
3945
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4046
return (page.value.git?.changelog ?? []).map(({ date, ...item }) => {
4147
const datetime = formatter.format(date)
@@ -63,12 +69,12 @@ export const Changelog = defineComponent({
6369
h('div', { class: 'changelog-header', onClick: toggle }, [
6470
h('div', { class: 'latest-updated' }, [
6571
h('span', { class: 'vpi-changelog' }),
66-
h('span', [locale.value.latestUpdated || 'Latest updated:', ' ']),
67-
h('span', { 'data-allow-mismatch': true }, latestUpdated.value),
72+
h('span', [locale.value.latestUpdateAt, ' ']),
73+
h('span', { 'data-allow-mismatch': '' }, latestUpdated.value),
6874
]),
6975
h('div', [
7076
h('span', { class: 'vpi-changelog-menu' }),
71-
h('span', locale.value.changelogButton || 'View All Changelog'),
77+
h('span', locale.value.viewChangelog),
7278
]),
7379
])
7480

@@ -80,8 +86,8 @@ export const Changelog = defineComponent({
8086
{ class: 'changelog release-tag' },
8187
h('div', [
8288
h('a', { class: 'link release-tag' }, h('code', item.tag)),
83-
h('span', { 'class': 'datetime', 'data-allow-mismatch': true }, [
84-
locale.value.changelogOn || 'on',
89+
h('span', { 'class': 'datetime', 'data-allow-mismatch': '' }, [
90+
locale.value.timeOn,
8591
' ',
8692
item.datetime,
8793
]),
@@ -104,8 +110,8 @@ export const Changelog = defineComponent({
104110
),
105111
h('span', { class: 'divider' }, '-'),
106112
h('span', { class: 'message', innerHTML: item.message }),
107-
h('span', { 'class': 'datetime', 'data-allow-mismatch': true }, [
108-
locale.value.changelogOn || 'on',
113+
h('span', { 'class': 'datetime', 'data-allow-mismatch': '' }, [
114+
locale.value.timeOn || 'on',
109115
' ',
110116
item.datetime,
111117
]),
@@ -117,7 +123,7 @@ export const Changelog = defineComponent({
117123
h(VPHeader, {
118124
level: props.headerLevel,
119125
anchor: 'doc-changelog',
120-
title: props.title || locale.value.changelog || 'Changelog',
126+
text: props.title || locale.value.changelog,
121127
}),
122128

123129
h('div', { class: ['vp-changelog', { active: active.value }] }, [

plugins/development/plugin-git/src/client/components/Contributors.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ import type {
66
GitPluginFrontmatter,
77
GitPluginPageData,
88
} from '../../shared/index.js'
9-
import { useGitLocales } from '../composables/index.js'
9+
import { useGitLocaleConfig } from '../composables/index.js'
1010
import { VPHeader } from './VPHeader.js'
1111

1212
import '../styles/contributors.css'
1313

1414
export const Contributors = defineComponent({
1515
name: 'Contributors',
1616
props: {
17+
/** Contributor title */
18+
title: String,
19+
20+
/** header level of contributor title */
1721
headerLevel: {
1822
type: Number,
1923
default: 2,
2024
},
21-
title: String,
2225
},
2326
setup(props) {
24-
const page = usePageData<GitPluginPageData>()
27+
const locale = useGitLocaleConfig()
2528
const frontmatter = usePageFrontmatter<GitPluginFrontmatter>()
26-
const locale = useGitLocales()
29+
const page = usePageData<GitPluginPageData>()
2730

2831
const contributors = computed(() => {
2932
if (frontmatter.value.contributors === false) return []
@@ -56,7 +59,7 @@ export const Contributors = defineComponent({
5659
h(VPHeader, {
5760
level: props.headerLevel,
5861
anchor: 'doc-contributors',
59-
title: props.title || locale.value.contributors || 'Contributors',
62+
text: props.title || locale.value.contributors,
6063
}),
6164
h(
6265
'div',
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import type { FunctionalComponent } from 'vue'
22
import { h } from 'vue'
33

4-
interface VPHeaderProps {
5-
level?: number
6-
title: string
4+
export interface VPHeaderProps {
5+
/** header text */
6+
text: string
7+
/** header anchor */
78
anchor: string
9+
/**
10+
* header level
11+
*
12+
* @default 2
13+
*/
14+
level?: number
815
}
916

1017
export const VPHeader: FunctionalComponent<VPHeaderProps> = ({
1118
level = 2,
12-
title,
19+
text,
1320
anchor,
1421
}) =>
1522
h(
1623
`h${level || 2}`,
1724
{ id: anchor, tabindex: '-1' },
18-
h('a', { href: `#${anchor}`, class: 'header-anchor' }, h('span', title)),
25+
h('a', { href: `#${anchor}`, class: 'header-anchor' }, h('span', text)),
1926
)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { ExactLocaleConfig } from '@vuepress/helper/client'
12
import { useLocaleConfig } from '@vuepress/helper/client'
23
import type { ComputedRef } from 'vue'
3-
import type { GitLocaleData, GitLocales } from '../../shared/index.js'
4+
import type { GitLocaleData } from '../../shared/index.js'
45

5-
declare const __GIT_LOCALES__: GitLocales
6+
declare const __GIT_LOCALES__: ExactLocaleConfig<GitLocaleData>
67

78
export const locales = __GIT_LOCALES__
89

9-
export const useGitLocales = (): ComputedRef<Partial<GitLocaleData>> =>
10+
export const useGitLocaleConfig = (): ComputedRef<GitLocaleData> =>
1011
useLocaleConfig(locales)

plugins/development/plugin-git/src/node/gitPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
GitPluginFrontmatter,
77
GitPluginPageData,
88
} from '../shared/index.js'
9-
import { DEFAULT_LOCALES } from './locales.js'
9+
import { gitLocaleInfo } from './locales.js'
1010
import type { GitPluginOptions } from './options.js'
1111
import { resolveChangelog } from './resolveChangelog.js'
1212
import { resolveContributors } from './resolveContributors.js'
@@ -35,7 +35,7 @@ export const gitPlugin =
3535
__GIT_LOCALES__: getFullLocaleConfig({
3636
app,
3737
name,
38-
default: DEFAULT_LOCALES,
38+
default: gitLocaleInfo,
3939
config: locales,
4040
}),
4141
},

0 commit comments

Comments
 (0)