Skip to content

Commit

Permalink
fix: edit page from Bitbucket (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
daltondiaz authored and ulivz committed Jun 12, 2018
1 parent cfce3dc commit 5479d6e
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
)
}
}
}
Expand Down

0 comments on commit 5479d6e

Please sign in to comment.