mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 09:50:33 +01:00
fix(inertia): link always render as anchor tag (#3989)
Co-authored-by: Benjamin Canac <canacb1@gmail.com> Co-authored-by: Eugen Istoc <eugenistoc@gmail.com> Co-authored-by: Romain Hamel <rom.hml@gmail.com>
This commit is contained in:
@@ -95,6 +95,7 @@ const ui = computed(() => tv({
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
const isExternal = computed(() => {
|
const isExternal = computed(() => {
|
||||||
|
if (props.external) return true
|
||||||
if (!props.to) return false
|
if (!props.to) return false
|
||||||
return typeof props.to === 'string' && hasProtocol(props.to, { acceptRelative: true })
|
return typeof props.to === 'string' && hasProtocol(props.to, { acceptRelative: true })
|
||||||
})
|
})
|
||||||
@@ -110,14 +111,14 @@ const linkClass = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const page = usePage()
|
const page = usePage()
|
||||||
const url = computed(() => props.to ?? props.href ?? '#')
|
const url = computed(() => props.to ?? props.href ?? '')
|
||||||
|
|
||||||
const isActive = computed(() => props.active || (props.exact ? url.value === props.href : page?.url.startsWith(url.value)))
|
const isActive = computed(() => props.active || (!!url.value && (props.exact ? url.value === props.href : page?.url.startsWith(url.value))))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<template v-if="!isExternal">
|
<template v-if="!isExternal && !!url">
|
||||||
<InertiaLink v-bind="routerLinkProps" :href="url" custom>
|
<InertiaLink v-bind="routerLinkProps" :href="url">
|
||||||
<template v-if="custom">
|
<template v-if="custom">
|
||||||
<slot
|
<slot
|
||||||
v-bind="{
|
v-bind="{
|
||||||
|
|||||||
Reference in New Issue
Block a user