From fa8eee98feb4e5aebfa843a93656537b92d142b8 Mon Sep 17 00:00:00 2001 From: Jason Yu Date: Fri, 20 Apr 2018 10:22:40 +0100 Subject: [PATCH] added option to customise repoLabel --- docs/default-theme-config/README.md | 4 +++- lib/default-theme/NavLinks.vue | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/default-theme-config/README.md b/docs/default-theme-config/README.md index 6e7056e2c2..e0ead0e76b 100644 --- a/docs/default-theme-config/README.md +++ b/docs/default-theme-config/README.md @@ -216,7 +216,7 @@ next: false --- ``` -## GitHub Repo and Edit Links +## 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. @@ -226,6 +226,8 @@ module.exports = { themeConfig: { // Assumes GitHub. Can also be a full GitLab url. repo: 'vuejs/vuepress', + // Customising the header label + repoLabel: 'Contribute!', // if your docs are not at the root of the repo docsDir: 'docs', // optional, defaults to master diff --git a/lib/default-theme/NavLinks.vue b/lib/default-theme/NavLinks.vue index 0989669634..216a076164 100644 --- a/lib/default-theme/NavLinks.vue +++ b/lib/default-theme/NavLinks.vue @@ -78,6 +78,8 @@ export default { } }, repoLabel () { + if (this.$site.themeConfig.repoLabel) return this.$site.themeConfig.repoLabel + const repoHost = this.repoLink.match(/^https?:\/\/[^/]+/)[0] || 'github' return ['GitHub', 'GitLab', 'Bitbucket'].find(platform => { return repoHost.toLowerCase().includes(platform.toLowerCase())