Skip to content

Commit

Permalink
feat($theme-default): support nav config for attr of external links
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 committed Aug 1, 2019
1 parent 702e947 commit 2fecdb3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/@vuepress/theme-default/components/NavLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
<OutboundLink/>
<OutboundLink v-if="isTargetBlank"/>
</a>
</template>

Expand All @@ -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.isTargetBlank ? 'noopener noreferrer' : this.item.rel
}
},
Expand Down

0 comments on commit 2fecdb3

Please sign in to comment.