File tree 2 files changed +31
-11
lines changed
docs/default-theme-config
2 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ next: false
216
216
---
217
217
```
218
218
219
- ## GitHub Repo and Edit Links
219
+ ## Git Repo and Edit Links
220
220
221
221
Providing ` themeConfig.repo ` auto generates a GitHub link in the navbar and "Edit this page" links at the bottom of each page.
222
222
@@ -226,6 +226,9 @@ module.exports = {
226
226
themeConfig: {
227
227
// Assumes GitHub. Can also be a full GitLab url.
228
228
repo: ' vuejs/vuepress' ,
229
+ // Customising the header label
230
+ // Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
231
+ repoLabel: ' Contribute!' ,
229
232
// if your docs are not at the root of the repo
230
233
docsDir: ' docs' ,
231
234
// optional, defaults to master
Original file line number Diff line number Diff line change 1
1
<template >
2
- <nav class =" nav-links" v-if =" userLinks.length || githubLink " >
2
+ <nav class =" nav-links" v-if =" userLinks.length || repoLink " >
3
3
<!-- user links -->
4
4
<div
5
5
class =" nav-item"
8
8
<DropdownLink v-if =" item.type === 'links'" :item =" item" />
9
9
<NavLink v-else :item =" item" />
10
10
</div >
11
- <!-- github link -->
12
- <a v-if =" githubLink "
13
- :href =" githubLink "
14
- class =" github -link"
11
+ <!-- repo link -->
12
+ <a v-if =" repoLink "
13
+ :href =" repoLink "
14
+ class =" repo -link"
15
15
target =" _blank"
16
16
rel =" noopener noreferrer" >
17
- GitHub
17
+ {{ repoLabel }}
18
18
<OutboundLink />
19
19
</a >
20
20
</nav >
@@ -69,14 +69,31 @@ export default {
69
69
})
70
70
}))
71
71
},
72
- githubLink () {
72
+ repoLink () {
73
73
const { repo } = this .$site .themeConfig
74
74
if (repo) {
75
75
return / ^ https? :/ .test (repo)
76
76
? repo
77
77
: ` https://github.com/${ repo} `
78
78
}
79
- }
79
+ },
80
+ repoLabel () {
81
+ if (! this .repoLink ) return
82
+ if (this .$site .themeConfig .repoLabel ) {
83
+ return this .$site .themeConfig .repoLabel
84
+ }
85
+
86
+ const repoHost = this .repoLink .match (/ ^ https? :\/\/ [^ /] + / )[0 ]
87
+ const platforms = [' GitHub' , ' GitLab' , ' Bitbucket' ]
88
+ for (let i = 0 ; i < platforms .length ; i++ ) {
89
+ const platform = platforms[i]
90
+ if (new RegExp (platform, ' i' ).test (repoHost)) {
91
+ return platform
92
+ }
93
+ }
94
+
95
+ return ' Source'
96
+ },
80
97
},
81
98
methods: {
82
99
isActive
@@ -100,12 +117,12 @@ export default {
100
117
display inline-block
101
118
margin-left 1.5rem
102
119
line-height 2rem
103
- .github -link
120
+ .repo -link
104
121
margin-left 1.5rem
105
122
106
123
@media (max-width : $MQMobile)
107
124
.nav-links
108
- .nav-item , .github -link
125
+ .nav-item , .repo -link
109
126
margin-left 0
110
127
111
128
@media (min-width : $MQMobile)
You can’t perform that action at this time.
0 commit comments