mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
fix(theme): improve link handling and href binding logic
This commit is contained in:
parent
61ca08c8b4
commit
f9276fdb75
@ -19,10 +19,9 @@ const tag = computed(() => props.tag ?? (props.href ? 'a' : 'span'))
|
||||
const { link, isExternal } = useLink(toRef(props, 'href'), toRef(props, 'target'))
|
||||
|
||||
function linkTo(e: Event) {
|
||||
if (!isExternal.value) {
|
||||
if (!isExternal.value && link.value) {
|
||||
e.preventDefault()
|
||||
if (link.value)
|
||||
router.push(link.value)
|
||||
router.push(link.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -30,7 +29,7 @@ function linkTo(e: Event) {
|
||||
<template>
|
||||
<Component
|
||||
:is="tag" class="vp-link no-icon" :class="{ link }"
|
||||
:href="withBase(link || '')"
|
||||
:href="link ? withBase(link) : undefined"
|
||||
:target="target ?? (isExternal ? '_blank' : undefined)"
|
||||
:rel="rel ?? (isExternal ? 'noreferrer' : undefined)"
|
||||
@click="linkTo($event)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user