Skip to content

Commit e88caf2

Browse files
committed
feat($theme-default): support nav config for attr of external links
fix vuejs#1353
1 parent 702e947 commit e88caf2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/@vuepress/theme-default/components/NavLink.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
v-else
1010
:href="link"
1111
class="nav-link external"
12-
:target="isMailto(link) || isTel(link) ? null : '_blank'"
13-
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
12+
:target="target"
13+
:rel="rel"
1414
>
1515
{{ item.text }}
16-
<OutboundLink/>
16+
<OutboundLink v-if="isTargetBlank"/>
1717
</a>
1818
</template>
1919

@@ -37,6 +37,18 @@ export default {
3737
return Object.keys(this.$site.locales).some(rootLink => rootLink === this.link)
3838
}
3939
return this.link === '/'
40+
},
41+
42+
target () {
43+
return isMailto(this.link) || isTel(this.link) ? null : this.item.target || '_blank'
44+
},
45+
46+
isTargetBlank () {
47+
return this.target === '_blank'
48+
},
49+
50+
rel () {
51+
return isMailto(this.link) || isTel(this.link) ? null : this.item.rel || 'noopener noreferrer'
4052
}
4153
},
4254

0 commit comments

Comments
 (0)