mirror of
https://github.com/imezx/Warp.git
synced 2025-04-25 15:40:02 +00:00
34 lines
808 B
Vue
34 lines
808 B
Vue
|
<script lang="ts" setup>
|
||
|
import { computed } from 'vue'
|
||
|
import { normalizeLink } from '../support/utils'
|
||
|
import { EXTERNAL_URL_RE } from '../../shared'
|
||
|
|
||
|
const props = defineProps<{
|
||
|
tag?: string
|
||
|
href?: string
|
||
|
noIcon?: boolean
|
||
|
target?: string
|
||
|
rel?: string
|
||
|
}>()
|
||
|
|
||
|
const tag = computed(() => props.tag ?? (props.href ? 'a' : 'span'))
|
||
|
const isExternal = computed(() => props.href && EXTERNAL_URL_RE.test(props.href))
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<component
|
||
|
:is="tag"
|
||
|
class="VPLink"
|
||
|
:class="{
|
||
|
link: href,
|
||
|
'vp-external-link-icon': isExternal,
|
||
|
'no-icon': noIcon
|
||
|
}"
|
||
|
:href="href ? normalizeLink(href) : undefined"
|
||
|
:target="target ?? (isExternal ? '_blank' : undefined)"
|
||
|
:rel="rel ?? (isExternal ? 'noreferrer' : undefined)"
|
||
|
>
|
||
|
<slot />
|
||
|
</component>
|
||
|
</template>
|