Skip to content

Commit 716aefe

Browse files
wangyi7099yyx990803
authored andcommitted
feat: Add docsRepo (#155)
1 parent d026801 commit 716aefe

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

docs/default-theme-config/README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,14 @@ module.exports = {
229229
// Customising the header label
230230
// Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
231231
repoLabel: 'Contribute!',
232-
// if your docs are not at the root of the repo
232+
233+
// Optional options for generating "Edit this page" link
234+
235+
// if your docs are in a different repo from your main project:
236+
docsRepo: 'vuejs/vuepress',
237+
// if your docs are not at the root of the repo:
233238
docsDir: 'docs',
234-
// optional, defaults to master
239+
// if your docs are in a specific branch (defaults to 'master'):
235240
docsBranch: 'master',
236241
// defaults to true, set to false to disable
237242
editLinks: true,

docs/zh/default-theme-config/README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ next: false
214214
---
215215
```
216216

217-
## Github 和编辑链接
217+
## Git 仓库和编辑链接
218218

219219
当你提供了 `themeConfig.repo` 选项,将会自动在每个页面的导航栏生成生成一个 GitHub 链接,以及在页面的底部生成一个 `"Edit this page"` 链接。
220220

@@ -224,10 +224,18 @@ module.exports = {
224224
themeConfig: {
225225
// 假定是 GitHub. 同时也可以是一个完整的 GitLab URL
226226
repo: 'vuejs/vuepress',
227-
// 当你的文档不是仓库的根目录时需要设置
228-
docsDir: 'docs',
229-
// 可选的, 默认是 master
230-
docsBranch: 'master',
227+
   // 自定义仓库链接文字。默认从 `themeConfig.repo` 中自动推断为
228+
   // "GitHub"/"GitLab"/"Bitbucket" 其中之一,或是 "Source"。
229+
   repoLabel: '查看源码',
230+
231+
   // 以下为可选的编辑链接选项
232+
233+
   // 假如你的文档仓库和项目本身不在一个仓库:
234+
   docsRepo: 'vuejs/vuepress',
235+
   // 假如文档不是放在仓库的根目录下:
236+
   docsDir: 'docs',
237+
   // 假如文档放在一个特定的分支下:
238+
   docsBranch: 'master',
231239
// 默认是 true, 设置为 false 来禁用
232240
editLinks: true,
233241
// 默认为 "Edit this page"

lib/default-theme/Page.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export default {
5555
repo,
5656
editLinks,
5757
docsDir = '',
58-
docsBranch = 'master'
58+
docsBranch = 'master',
59+
docsRepo = repo
5960
} = this.$site.themeConfig
6061
6162
let path = normalize(this.$page.path)
@@ -65,10 +66,10 @@ export default {
6566
path += '.md'
6667
}
6768
68-
if (repo && editLinks) {
69-
const base = outboundRE.test(repo)
70-
? repo
71-
: `https://github.com/${repo}`
69+
if (docsRepo && editLinks) {
70+
const base = outboundRE.test(docsRepo)
71+
? docsRepo
72+
: `https://github.com/${docsRepo}`
7273
return (
7374
base.replace(endingSlashRE, '') +
7475
`/edit/${docsBranch}/` +

0 commit comments

Comments
 (0)