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 + ) + } } }