Skip to content

Commit

Permalink
feat: Add docsRepo (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyi7099 authored and yyx990803 committed Apr 23, 2018
1 parent d026801 commit 716aefe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
9 changes: 7 additions & 2 deletions docs/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ module.exports = {
// Customising the header label
// Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
repoLabel: 'Contribute!',
// if your docs are not at the root of the repo

// Optional options for generating "Edit this page" link

// if your docs are in a different repo from your main project:
docsRepo: 'vuejs/vuepress',
// if your docs are not at the root of the repo:
docsDir: 'docs',
// optional, defaults to master
// if your docs are in a specific branch (defaults to 'master'):
docsBranch: 'master',
// defaults to true, set to false to disable
editLinks: true,
Expand Down
18 changes: 13 additions & 5 deletions docs/zh/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ next: false
---
```

## Github 和编辑链接
## Git 仓库和编辑链接

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

Expand All @@ -224,10 +224,18 @@ module.exports = {
themeConfig: {
// 假定是 GitHub. 同时也可以是一个完整的 GitLab URL
repo: 'vuejs/vuepress',
// 当你的文档不是仓库的根目录时需要设置
docsDir: 'docs',
// 可选的, 默认是 master
docsBranch: 'master',
   // 自定义仓库链接文字。默认从 `themeConfig.repo` 中自动推断为
   // "GitHub"/"GitLab"/"Bitbucket" 其中之一,或是 "Source"。
   repoLabel: '查看源码',

   // 以下为可选的编辑链接选项

   // 假如你的文档仓库和项目本身不在一个仓库:
   docsRepo: 'vuejs/vuepress',
   // 假如文档不是放在仓库的根目录下:
   docsDir: 'docs',
   // 假如文档放在一个特定的分支下:
   docsBranch: 'master',
// 默认是 true, 设置为 false 来禁用
editLinks: true,
// 默认为 "Edit this page"
Expand Down
11 changes: 6 additions & 5 deletions lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default {
repo,
editLinks,
docsDir = '',
docsBranch = 'master'
docsBranch = 'master',
docsRepo = repo
} = this.$site.themeConfig
let path = normalize(this.$page.path)
Expand All @@ -65,10 +66,10 @@ export default {
path += '.md'
}
if (repo && editLinks) {
const base = outboundRE.test(repo)
? repo
: `https://github.com/${repo}`
if (docsRepo && editLinks) {
const base = outboundRE.test(docsRepo)
? docsRepo
: `https://github.com/${docsRepo}`
return (
base.replace(endingSlashRE, '') +
`/edit/${docsBranch}/` +
Expand Down

0 comments on commit 716aefe

Please sign in to comment.