50 lines
719 B
Vue
50 lines
719 B
Vue
|
<template>
|
||
|
<div>
|
||
|
<div v-if="isExternal">
|
||
|
<a :href="to">
|
||
|
<span
|
||
|
:class="`fa fa-lg fa-fw ${fa}`"
|
||
|
aria-hidden="true"
|
||
|
/>
|
||
|
|
||
|
<slot/>
|
||
|
</a>
|
||
|
|
||
|
<span
|
||
|
class="fa fa-lg fa-fw fa-external-link"
|
||
|
aria-hidden="true"
|
||
|
/>
|
||
|
</div>
|
||
|
<router-link
|
||
|
v-else
|
||
|
v-bind="$props"
|
||
|
>
|
||
|
<span
|
||
|
:class="`fa fa-lg fa-fw ${fa}`"
|
||
|
aria-hidden="true"
|
||
|
/>
|
||
|
|
||
|
<slot/>
|
||
|
</router-link>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { RouterLink } from 'vue-router'
|
||
|
|
||
|
export default {
|
||
|
props: {
|
||
|
...RouterLink.props,
|
||
|
fa: {
|
||
|
type: String,
|
||
|
default: ''
|
||
|
}
|
||
|
},
|
||
|
computed: {
|
||
|
isExternal() {
|
||
|
return typeof this.to === 'string' && this.to.startsWith('http')
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|