mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-20 07:30:57 +00:00
chore: minor changes
This commit is contained in:
parent
b71f3fec98
commit
7d8fb2c4d9
@ -136,7 +136,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
ariaCurrentValue: {
|
ariaCurrentValue: {
|
||||||
type: String as PropType<string>,
|
type: String as PropType<RouterLinkProps['ariaCurrentValue']>,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
@ -171,9 +171,11 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
return typeof link.value === 'string' ? link.value : router.resolve(link.value).path
|
return typeof link.value === 'string' ? link.value : router.resolve(link.value).path
|
||||||
})
|
})
|
||||||
const as = computed(() => {
|
const as = computed(() => {
|
||||||
const isExternalLink = hasProtocol(href.value, { acceptRelative: true })
|
|
||||||
const forceAnchorTag = props.external
|
const forceAnchorTag = props.external
|
||||||
return !forceAnchorTag && !isExternalLink ? 'RouterLink' : 'a'
|
if (forceAnchorTag || hasProtocol(href.value, { acceptRelative: true })) {
|
||||||
|
return 'a'
|
||||||
|
}
|
||||||
|
return 'RouterLink'
|
||||||
})
|
})
|
||||||
|
|
||||||
const routerLinkProps = computed(() => {
|
const routerLinkProps = computed(() => {
|
||||||
@ -328,17 +330,13 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
export default defineNuxtLink(nuxtLinkDefaults)
|
export default defineNuxtLink(nuxtLinkDefaults)
|
||||||
|
|
||||||
// -- NuxtLink utils --
|
// -- NuxtLink utils --
|
||||||
function applyTrailingSlashBehavior (to: string, trailingSlash?: NuxtLinkOptions['trailingSlash']): string {
|
function applyTrailingSlashBehavior (path: string, trailingSlash?: NuxtLinkOptions['trailingSlash']): string {
|
||||||
if (!trailingSlash || !to) {
|
// path should always be relative here
|
||||||
return to
|
if (!trailingSlash || !path) {
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
const normalizeFn = trailingSlash === 'append' ? withTrailingSlash : withoutTrailingSlash
|
const normalizeFn = trailingSlash === 'append' ? withTrailingSlash : withoutTrailingSlash
|
||||||
// Until https://github.com/unjs/ufo/issues/189 is resolved
|
return normalizeFn(path, true)
|
||||||
const hasProtocolDifferentFromHttp = hasProtocol(to) && !to.startsWith('http')
|
|
||||||
if (hasProtocolDifferentFromHttp) {
|
|
||||||
return to
|
|
||||||
}
|
|
||||||
return normalizeFn(to, true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Prefetching utils ---
|
// --- Prefetching utils ---
|
||||||
|
Loading…
Reference in New Issue
Block a user