Skip to content

Commit 5479d6e

Browse files
daltondiazulivz
authored andcommitted
fix: edit page from Bitbucket (#569)
1 parent cfce3dc commit 5479d6e

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

Diff for: lib/default-theme/Page.vue

+29-10
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,8 @@ export default {
8787
} else {
8888
path += '.md'
8989
}
90-
9190
if (docsRepo && editLinks) {
92-
const base = outboundRE.test(docsRepo)
93-
? docsRepo
94-
: `https://github.com/${docsRepo}`
95-
return (
96-
base.replace(endingSlashRE, '') +
97-
`/edit/${docsBranch}` +
98-
(docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') +
99-
path
100-
)
91+
return this.createEditLink(repo, docsRepo, docsDir, docsBranch, path)
10192
}
10293
},
10394
editLinkText () {
@@ -107,6 +98,34 @@ export default {
10798
`Edit this page`
10899
)
109100
}
101+
},
102+
methods: {
103+
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
104+
const bitbucket = /bitbucket.org/
105+
if (bitbucket.test(repo)) {
106+
const base = outboundRE.test(docsRepo)
107+
? docsRepo
108+
: repo
109+
return (
110+
base.replace(endingSlashRE, '') +
111+
`/${docsBranch}` +
112+
(docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') +
113+
path +
114+
`?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`
115+
)
116+
}
117+
118+
const base = outboundRE.test(docsRepo)
119+
? docsRepo
120+
: `https://github.com/${docsRepo}`
121+
122+
return (
123+
base.replace(endingSlashRE, '') +
124+
`/edit/${docsBranch}` +
125+
(docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') +
126+
path
127+
)
128+
}
110129
}
111130
}
112131

0 commit comments

Comments
 (0)