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

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