Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat($default-theme): Support Azure Repos url for page edition (Closes #1959) #1960

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/@vuepress/theme-default/components/PageEdit.vue
Expand Up @@ -68,6 +68,7 @@ export default {
methods: {
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
const bitbucket = /bitbucket.org/
const azurerepos = /dev\.azure\.com|\w+\.visualstudio\.com/
if (bitbucket.test(repo)) {
const base = outboundRE.test(docsRepo) ? docsRepo : repo
return (
Expand All @@ -80,6 +81,17 @@ export default {
)
}

if (azurerepos.test(repo)) {
const base = outboundRE.test(docsRepo) ? docsRepo : repo
return (
base.replace(endingSlashRE, '')
+ `?path=`
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
+ path
+ `&version=GBmaster`
)
}

const base = outboundRE.test(docsRepo)
? docsRepo
: `https://github.com/${docsRepo}`
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/docs/theme/default-theme-config.md
Expand Up @@ -414,7 +414,7 @@ next: false

## Git repository and Edit Links

Providing `themeConfig.repo` auto generates a GitHub link in the navbar and "Edit this page" links at the bottom of each page.
Providing `themeConfig.repo` auto generates a repository link in the navbar and "Edit this page" links at the bottom of each page.

``` js
// .vuepress/config.js
Expand All @@ -423,7 +423,7 @@ module.exports = {
// Assumes GitHub. Can also be a full GitLab url.
repo: 'vuejs/vuepress',
// Customising the header label
// Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
// Defaults to "GitHub"/"GitLab"/"Bitbucket"/"Azure Repos" depending on `themeConfig.repo`
repoLabel: 'Contribute!',

// Optional options for generating "Edit this page" link
Expand Down