Skip to content

Commit 6f5bac0

Browse files
committed
feat: i18n for edit link text
1 parent d666872 commit 6f5bac0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs/.vuepress/config.js

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ module.exports = {
6565
sidebar: {
6666
'/guide/': genSidebarConfig('Guide'),
6767
'/zh/guide/': genSidebarConfig('指南')
68+
},
69+
editLinkText: {
70+
'/zh/': '在 GitHub 上编辑此页'
6871
}
6972
}
7073
}
@@ -82,6 +85,7 @@ function genSidebarConfig (title) {
8285
'markdown',
8386
'using-vue',
8487
'custom-themes',
88+
'i18n',
8589
'deploy'
8690
]
8791
}

lib/default-theme/Page.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="page">
33
<Content :custom="false"/>
44
<div class="content edit-link" v-if="editLink">
5-
<a :href="editLink" target="_blank" rel="noopener noreferrer">Edit this page</a>
5+
<a :href="editLink" target="_blank" rel="noopener noreferrer">{{ editLinkText }}</a>
66
<OutboundLink/>
77
</div>
88
<div class="content page-nav" v-if="prev || next">
@@ -76,6 +76,17 @@ export default {
7676
path
7777
)
7878
}
79+
},
80+
editLinkText () {
81+
const defualtValue = `Edit this page`
82+
const { editLinkText } = this.$site.themeConfig
83+
if (!editLinkText) {
84+
return defualtValue
85+
} else if (typeof editLinkText === 'string') {
86+
return editLinkText
87+
} else if (typeof editLinkText === 'object') {
88+
return editLinkText[this.$localePath] || defualtValue
89+
}
7990
}
8091
}
8192
}

0 commit comments

Comments
 (0)