Files
yiliang114 e27eb50565 feat:
vuepress@1.x config change and style use
2020-02-12 14:53:42 +08:00

45 lines
890 B
Vue

<template>
<router-link class="nav-link"
:to="link"
v-if="!isExternal(link)"
:exact="exact">{{ 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'">
{{ item.text }}
<OutboundLink />
</a>
</template>
<script>
import { isExternal, isMailto, isTel, ensureExt } from "../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>