|
|
@ -8,52 +8,25 @@ export function useNavLink(item: DefaultTheme.NavItemWithLink) {
|
|
|
|
const route = useRoute()
|
|
|
|
const route = useRoute()
|
|
|
|
const { withBase } = useUrl()
|
|
|
|
const { withBase } = useUrl()
|
|
|
|
|
|
|
|
|
|
|
|
const classes = computed(() => ({
|
|
|
|
const isExternal = isExternalCheck(item.link)
|
|
|
|
active: isActive.value,
|
|
|
|
|
|
|
|
external: isExternal.value
|
|
|
|
const props = computed(() => {
|
|
|
|
}))
|
|
|
|
return {
|
|
|
|
|
|
|
|
class: {
|
|
|
|
const isActive = computed(() => {
|
|
|
|
active:
|
|
|
|
return normalizePath(withBase(item.link)) === normalizePath(route.path)
|
|
|
|
normalizePath(withBase(item.link)) === normalizePath(route.path),
|
|
|
|
})
|
|
|
|
isExternal
|
|
|
|
|
|
|
|
},
|
|
|
|
const isExternal = computed(() => {
|
|
|
|
href: isExternal ? item.link : withBase(item.link),
|
|
|
|
return isExternalCheck(item.link)
|
|
|
|
target: item.target || isExternal ? `_blank` : null,
|
|
|
|
})
|
|
|
|
rel: item.rel || isExternal ? `noopener noreferrer` : null,
|
|
|
|
|
|
|
|
'aria-label': item.ariaLabel
|
|
|
|
const href = computed(() => {
|
|
|
|
|
|
|
|
return isExternal.value ? item.link : withBase(item.link)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const target = computed(() => {
|
|
|
|
|
|
|
|
if (item.target) {
|
|
|
|
|
|
|
|
return item.target
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return isExternal.value ? '_blank' : ''
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const rel = computed(() => {
|
|
|
|
|
|
|
|
if (item.rel) {
|
|
|
|
|
|
|
|
return item.rel
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return isExternal.value ? 'noopener noreferrer' : ''
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ariaLabel = computed(() => item.ariaLabel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const text = computed(() => item.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
classes,
|
|
|
|
props,
|
|
|
|
isActive,
|
|
|
|
isExternal
|
|
|
|
isExternal,
|
|
|
|
|
|
|
|
href,
|
|
|
|
|
|
|
|
target,
|
|
|
|
|
|
|
|
rel,
|
|
|
|
|
|
|
|
ariaLabel,
|
|
|
|
|
|
|
|
text
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|