mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-13 15:25:51 +10:00
37 lines
618 B
Vue
37 lines
618 B
Vue
<template>
|
|
<router-link
|
|
class="nav-link"
|
|
:to="link"
|
|
v-if="!isExternal(link)"
|
|
:exact="link === '/'"
|
|
>{{ item.text }}</router-link>
|
|
<a
|
|
v-else
|
|
:href="link"
|
|
class="nav-link"
|
|
:target="isMailto(link) ? null : '_blank'"
|
|
:rel="isMailto(link) ? null : 'noopener noreferrer'"
|
|
>{{ item.text }}</a>
|
|
</template>
|
|
|
|
<script>
|
|
import { isExternal, isMailto, ensureExt } from './util'
|
|
|
|
export default {
|
|
props: {
|
|
item: {
|
|
required: true
|
|
}
|
|
},
|
|
computed: {
|
|
link() {
|
|
return ensureExt(this.item.link)
|
|
}
|
|
},
|
|
methods: {
|
|
isExternal,
|
|
isMailto
|
|
}
|
|
}
|
|
</script>
|