Skip to content

Commit

Permalink
feat($theme-default): support nav config for attr of internal links
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 committed Oct 11, 2019
1 parent e8f91f8 commit 377da36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/@vuepress/theme-default/components/NavLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="nav-link"
:to="link"
@focusout.native="focusoutAction"
v-if="!isExternal(link)"
v-if="isInternal"
:exact="exact"
>{{ item.text }}</router-link>
<a
Expand Down Expand Up @@ -42,22 +42,25 @@ export default {
},
target () {
return isMailto(this.link) || isTel(this.link) ? null : this.item.target || '_blank'
return isMailto(this.link) || isTel(this.link) ? null : this.item.target
|| (isExternal(this.link) ? '_blank' : '')
},
isTargetBlank () {
return this.target === '_blank'
},
rel () {
return isMailto(this.link) || isTel(this.link) ? null : this.item.rel || 'noopener noreferrer'
return isMailto(this.link) || isTel(this.link) ? null : this.item.rel
|| (this.isTargetBlank ? 'noopener noreferrer' : '')
},
isInternal () {
return !isExternal(this.link) && !this.isTargetBlank
}
},
methods: {
isExternal,
isMailto,
isTel,
focusoutAction () {
this.$emit('focusout')
}
Expand Down
1 change: 1 addition & 0 deletions packages/docs/docs/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
themeConfig: {
nav: [
{ text: 'External', link: 'https://google.com', target:'_self', rel:'' },
{ text: 'Guide', link: '/guide/', target:'_blank' }
]
}
}
Expand Down

0 comments on commit 377da36

Please sign in to comment.