vuepress-theme-reco/components/NavLink.vue
reco_luan 8994c5bb59 feat: Add component & optimization
1. Project optimization
2. Add module loading animation component
2019-12-05 14:59:03 +08:00

53 lines
990 B
Vue

<template>
<router-link
class="nav-link"
:to="link"
v-if="!isExternal(link)"
:exact="exact">
<i :class="`iconfont ${item.icon}`"></i>
{{ item.text }}
</router-link>
<a
v-else
:href="link"
class="nav-link external"
:target="isMailto(link) || isTel(link) ? null : '_blank'"
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
>
<i :class="`iconfont ${item.icon}`"></i>
{{ item.text }}
<OutboundLink/>
</a>
</template>
<script>
import { isExternal, isMailto, isTel, ensureExt } from '@theme/helpers/utils'
export default {
props: {
item: {
required: true
}
},
computed: {
link () {
return ensureExt(this.item.link)
},
exact () {
if (this.$site.locales) {
return Object.keys(this.$site.locales).some(rootLink => rootLink === this.link)
}
return this.link === '/'
}
},
methods: {
isExternal,
isMailto,
isTel
}
}
</script>