Skip to content

feat: specify the source of the page in the front matter #225

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ next: false
## Git Repo 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.
You can override the generated URL of the edit link for a particular page with a `source` attribute in the front matter.

``` js
// .vuepress/config.js
Expand Down
17 changes: 10 additions & 7 deletions lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@ export default {
docsBranch = 'master',
docsRepo = repo
} = this.$site.themeConfig
const source = this.$page.frontmatter.source

let path = normalize(this.$page.path)
if (endingSlashRE.test(path)) {
path += 'README.md'
} else {
path += '.md'
}
if (source && editLinks) {
return source.replace('/blob/', '/edit/')
} else if (docsRepo && editLinks) {
let path = normalize(this.$page.path)
if (endingSlashRE.test(path)) {
path += 'README.md'
} else {
path += '.md'
}

if (docsRepo && editLinks) {
const base = outboundRE.test(docsRepo)
? docsRepo
: `https://github.com/${docsRepo}`
Expand Down