From e88caf2023a11d6ea9c07fa48ac3af99cb7f21c3 Mon Sep 17 00:00:00 2001 From: Billyyyyy3320 Date: Thu, 1 Aug 2019 22:23:46 +0800 Subject: [PATCH] feat($theme-default): support nav config for attr of external links fix #1353 --- .../theme-default/components/NavLink.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/theme-default/components/NavLink.vue b/packages/@vuepress/theme-default/components/NavLink.vue index 452a1c6dc8..0bc382b4c2 100644 --- a/packages/@vuepress/theme-default/components/NavLink.vue +++ b/packages/@vuepress/theme-default/components/NavLink.vue @@ -9,11 +9,11 @@ v-else :href="link" class="nav-link external" - :target="isMailto(link) || isTel(link) ? null : '_blank'" - :rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'" + :target="target" + :rel="rel" > {{ item.text }} - + @@ -37,6 +37,18 @@ export default { return Object.keys(this.$site.locales).some(rootLink => rootLink === this.link) } return this.link === '/' + }, + + target () { + return isMailto(this.link) || isTel(this.link) ? null : this.item.target || '_blank' + }, + + isTargetBlank () { + return this.target === '_blank' + }, + + rel () { + return isMailto(this.link) || isTel(this.link) ? null : this.item.rel || 'noopener noreferrer' } },