Skip to content

Commit

Permalink
fix: fix outbound nav links (close #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 15, 2018
1 parent 8fc0336 commit c909007
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/default-theme/NavLinks.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<template>
<nav class="nav-links" v-if="userLinks.length || githubLink">
<!-- user links -->
<router-link v-for="item in userLinks"
:to="item.link"
:key="item.link"
:exact="item.link === '/'">
{{ item.text }}
</router-link>
<template v-for="item in userLinks">
<a v-if="item.isOutbound"
:href="item.link"
target="_blank"
rel="noopener noreferrer">
{{ item.text }}
</a>
<router-link
v-else
:to="item.link"
:key="item.link"
:exact="item.link === '/'">
{{ item.text }}
</router-link>
</template>
<!-- github link -->
<a v-if="githubLink"
:href="githubLink"
Expand All @@ -21,15 +30,16 @@

<script>
import OutboundLink from './OutboundLink.vue'
import { isActive, ensureExt } from './util'
import { isActive, ensureExt, outboundRE } from './util'
export default {
components: { OutboundLink },
computed: {
userLinks () {
return (this.$site.themeConfig.nav || []).map(item => ({
text: item.text,
link: ensureExt(item.link)
link: ensureExt(item.link),
isOutbound: outboundRE.test(item.link)
}))
},
githubLink () {
Expand Down

0 comments on commit c909007

Please sign in to comment.