Spookie/assets/js/components/AppLink.vue

49 lines
739 B
Vue
Raw Normal View History

2022-05-11 14:48:04 +02:00
<template>
<div>
<div v-if="isExternal">
<a :href="to">
<span
:class="`fa fa-lg fa-fw ${fa}`"
aria-hidden="true"
/>
&nbsp;
<slot/>
</a>
&nbsp;
<span
class="fa fa-lg fa-fw fa-external-link"
aria-hidden="true"
/>
</div>
<router-link
v-else
2022-05-23 16:25:55 +02:00
:to="{ name: props.to }"
2022-05-11 14:48:04 +02:00
>
<span
:class="`fa fa-lg fa-fw ${fa}`"
aria-hidden="true"
/>
&nbsp;
<slot/>
</router-link>
</div>
</template>
2022-05-23 16:25:55 +02:00
<script setup>
import { computed } from 'vue'
2022-05-11 14:48:04 +02:00
import { RouterLink } from 'vue-router'
2022-05-23 16:25:55 +02:00
const props = defineProps({
to: {
type: String,
required: true
2022-05-11 14:48:04 +02:00
},
2022-05-23 16:25:55 +02:00
fa: {
type: String,
default: ''
2022-05-11 14:48:04 +02:00
}
2022-05-23 16:25:55 +02:00
})
const isExternal = computed(() => props.to.startsWith('http'))
2022-05-11 14:48:04 +02:00
</script>