Skip to content

Commit

Permalink
chore(nav-link): do not destructure href
Browse files Browse the repository at this point in the history
To not lose reactivity
  • Loading branch information
stfsy committed Oct 28, 2022
1 parent 35bd297 commit 26774ab
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/components/nav-link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,22 @@ const clazz = computed(() => {
})

const isRelativeLink = computed(() => {
const { href } = props
return props.href[0] === '/' || href.indexOf('.') === -1
return props.href[0] === '/' || props.href.indexOf('.') === -1
})

const isExternalLink = computed(() => {
const { href } = props
const { hostname } = window.location
return !href.includes(hostname) && !isRelativeLink.value
return !props.href.includes(hostname) && !isRelativeLink.value
})

const hasAnchor = computed(() => {
const { href } = props
return !isExternalLink.value && href.includes('#')
return !isExternalLink.value && props.href.includes('#')
})

const isNonHttpLink = computed(() => {
const { href } = props
const containsProtocol = href.includes('://')
const containsProtocol = props.href.includes('://')
if (containsProtocol) {
return href.startsWith('http')
return props.href.startsWith('http')
} else {
return false
}
Expand Down

0 comments on commit 26774ab

Please sign in to comment.