<script setup lang="ts">
import { isExternal } from '~/utils/validate';
import { useRouter } from 'vue-router';
const router = useRouter()
const props = defineProps<{ to: string }>()

const linkTo = () => {
  router.push({ name: props.to })
}
</script>


<template>
  <a v-if="isExternal(props.to)" :href="props.to" target='_blank'>
    <slot></slot>
  </a>
  <div v-else @click="linkTo">
    <slot></slot>
  </div>
</template>
