diff --git a/lib/default-theme/Page.vue b/lib/default-theme/Page.vue index 9dfd9912a7..17957e7563 100644 --- a/lib/default-theme/Page.vue +++ b/lib/default-theme/Page.vue @@ -87,17 +87,8 @@ export default { } else { path += '.md' } - if (docsRepo && editLinks) { - const base = outboundRE.test(docsRepo) - ? docsRepo - : `https://github.com/${docsRepo}` - return ( - base.replace(endingSlashRE, '') + - `/edit/${docsBranch}` + - (docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') + - path - ) + return this.createEditLink(repo, docsRepo, docsDir, docsBranch, path) } }, editLinkText () { @@ -107,6 +98,34 @@ export default { `Edit this page` ) } + }, + methods: { + createEditLink (repo, docsRepo, docsDir, docsBranch, path) { + const bitbucket = /bitbucket.org/ + if (bitbucket.test(repo)) { + const base = outboundRE.test(docsRepo) + ? docsRepo + : repo + return ( + base.replace(endingSlashRE, '') + + `/${docsBranch}` + + (docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') + + path + + `?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default` + ) + } + + const base = outboundRE.test(docsRepo) + ? docsRepo + : `https://github.com/${docsRepo}` + + return ( + base.replace(endingSlashRE, '') + + `/edit/${docsBranch}` + + (docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') + + path + ) + } } } diff --git a/yarn.lock b/yarn.lock index 1b3c98886d..f7cf3dd183 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8292,7 +8292,7 @@ vue-jest@^2.6.0: tsconfig "^7.0.0" vue-template-es2015-compiler "^1.6.0" -vue-loader@^15.2.1: +vue-loader@^15.2.4: version "15.2.4" resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.2.4.tgz#a7b923123d3cf87230a8ff54a1c16d31a6c5dbb4" dependencies: