Skip to content

Commit

Permalink
feat: i18n for edit link text
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 18, 2018
1 parent d666872 commit 6f5bac0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ module.exports = {
sidebar: {
'/guide/': genSidebarConfig('Guide'),
'/zh/guide/': genSidebarConfig('指南')
},
editLinkText: {
'/zh/': '在 GitHub 上编辑此页'
}
}
}
Expand All @@ -82,6 +85,7 @@ function genSidebarConfig (title) {
'markdown',
'using-vue',
'custom-themes',
'i18n',
'deploy'
]
}
Expand Down
13 changes: 12 additions & 1 deletion lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="page">
<Content :custom="false"/>
<div class="content edit-link" v-if="editLink">
<a :href="editLink" target="_blank" rel="noopener noreferrer">Edit this page</a>
<a :href="editLink" target="_blank" rel="noopener noreferrer">{{ editLinkText }}</a>
<OutboundLink/>
</div>
<div class="content page-nav" v-if="prev || next">
Expand Down Expand Up @@ -76,6 +76,17 @@ export default {
path
)
}
},
editLinkText () {
const defualtValue = `Edit this page`
const { editLinkText } = this.$site.themeConfig
if (!editLinkText) {
return defualtValue
} else if (typeof editLinkText === 'string') {
return editLinkText
} else if (typeof editLinkText === 'object') {
return editLinkText[this.$localePath] || defualtValue
}
}
}
}
Expand Down

0 comments on commit 6f5bac0

Please sign in to comment.