This commit is contained in:
37
node_modules/vitepress/dist/client/theme-default/components/VPLink.vue
generated
vendored
Normal file
37
node_modules/vitepress/dist/client/theme-default/components/VPLink.vue
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<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)) ||
|
||||
props.target === '_blank'
|
||||
)
|
||||
</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>
|
Reference in New Issue
Block a user