Skip to content

Commit c909007

Browse files
committed
fix: fix outbound nav links (close #37)
1 parent 8fc0336 commit c909007

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lib/default-theme/NavLinks.vue

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
<template>
22
<nav class="nav-links" v-if="userLinks.length || githubLink">
33
<!-- user links -->
4-
<router-link v-for="item in userLinks"
5-
:to="item.link"
6-
:key="item.link"
7-
:exact="item.link === '/'">
8-
{{ item.text }}
9-
</router-link>
4+
<template v-for="item in userLinks">
5+
<a v-if="item.isOutbound"
6+
:href="item.link"
7+
target="_blank"
8+
rel="noopener noreferrer">
9+
{{ item.text }}
10+
</a>
11+
<router-link
12+
v-else
13+
:to="item.link"
14+
:key="item.link"
15+
:exact="item.link === '/'">
16+
{{ item.text }}
17+
</router-link>
18+
</template>
1019
<!-- github link -->
1120
<a v-if="githubLink"
1221
:href="githubLink"
@@ -21,15 +30,16 @@
2130

2231
<script>
2332
import OutboundLink from './OutboundLink.vue'
24-
import { isActive, ensureExt } from './util'
33+
import { isActive, ensureExt, outboundRE } from './util'
2534
2635
export default {
2736
components: { OutboundLink },
2837
computed: {
2938
userLinks () {
3039
return (this.$site.themeConfig.nav || []).map(item => ({
3140
text: item.text,
32-
link: ensureExt(item.link)
41+
link: ensureExt(item.link),
42+
isOutbound: outboundRE.test(item.link)
3343
}))
3444
},
3545
githubLink () {

0 commit comments

Comments
 (0)