Files
web-temp/layers/components/blocks/HybridLink.vue
2025-10-02 17:34:41 +09:00

40 lines
709 B
Vue

<script setup lang="ts">
import type { ClassType } from '#layers/types/Common'
interface Props {
to: string
target?: string
class?: ClassType
}
const props = withDefaults(defineProps<Props>(), {
target: '',
class: '',
})
const componentTag = computed(() => {
return props.target === '_blank' ? 'a' : 'AtomsLocaleLink'
})
const componentProps = computed(() => {
if (props.target === '_blank') {
return {
href: props.to,
target: props.target,
class: props.class,
}
}
return {
to: props.to,
class: props.class,
}
})
</script>
<template>
<component :is="componentTag" v-bind="{ ...$attrs, ...componentProps }">
<slot />
</component>
</template>