<template>
    <a :href="url" :target="target" class="strapi-link">{{ text }}</a>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
    text: String,
    url: String,
})

const target = computed(() => {
    if (!props.url) return '_self'
    const isAbsolute = /^(https?:|mailto:|tel:|\/\/)/.test(props.url)
    return isAbsolute ? '_blank' : '_self'
})
</script>

<style lang="scss">
.strapi-link {
}
</style>
