Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix($theme-default): fix editLink for repos hosted on gitlab.com (#2523)
* fix($theme-default): fix editLink for repos hosted on gitlab.com

* refactor($theme-default): refactor the gitlab edit links

* refactor($theme-default): refactor bitbucket edit links
  • Loading branch information
fulopkovacs committed Aug 3, 2020
1 parent 1be6c5b commit 1c3967c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/@vuepress/theme-default/components/PageEdit.vue
Expand Up @@ -80,8 +80,8 @@ export default {
methods: {
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
const bitbucket = /bitbucket.org/
if (bitbucket.test(repo)) {
const base = outboundRE.test(docsRepo) ? docsRepo : repo
if (bitbucket.test(docsRepo)) {
const base = docsRepo
return (
base.replace(endingSlashRE, '')
+ `/src`
Expand All @@ -92,12 +92,24 @@ export default {
)
}
const gitlab = /gitlab.com/
if (gitlab.test(docsRepo)) {
const base = docsRepo
return (
base.replace(endingSlashRE, '')
+ `/-/edit`
+ `/${docsBranch}/`
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
+ path
)
}
const base = outboundRE.test(docsRepo)
? docsRepo
: `https://github.com/${docsRepo}`
return (
base.replace(endingSlashRE, '')
+ `/edit`
+ '/edit'
+ `/${docsBranch}/`
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
+ path
Expand Down

0 comments on commit 1c3967c

Please sign in to comment.