Skip to content

Commit 2680b5a

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

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
@@ -11,11 +11,11 @@
1111
:href="link"
1212
@focusout="focusoutAction"
1313
class="nav-link external"
14-
:target="isMailto(link) || isTel(link) ? null : '_blank'"
15-
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
14+
:target="target"
15+
:rel="rel"
1616
>
1717
{{ item.text }}
18-
<OutboundLink/>
18+
<OutboundLink v-if="isTargetBlank"/>
1919
</a>
2020
</template>
2121

@@ -39,6 +39,18 @@ export default {
3939
return Object.keys(this.$site.locales).some(rootLink => rootLink === this.link)
4040
}
4141
return this.link === '/'
42+
},
43+
44+
target () {
45+
return isMailto(this.link) || isTel(this.link) ? null : this.item.target || '_blank'
46+
},
47+
48+
isTargetBlank () {
49+
return this.target === '_blank'
50+
},
51+
52+
rel () {
53+
return isMailto(this.link) || isTel(this.link) ? null : this.item.rel || 'noopener noreferrer'
4254
}
4355
},
4456

0 commit comments

Comments
 (0)