Skip to content

Commit

Permalink
🔍️ Do no overwrite href in NuxtLink with null
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Oct 19, 2023
1 parent 72ecae7 commit 6c3402a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions components/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<component
:is="tag"
:class="rootClasses"
:to="to || null"
:href="href || null"
:target="href ? '_blank' : null"
:rel="rel"
v-bind="attrs"
>
<slot />
<IconNorthEast v-if="href" class="ml-[4px] self-center" />
Expand All @@ -22,16 +19,25 @@ export default class Link extends Vue {
@Prop(String) readonly href: string | undefined
@Prop({ default: false }) readonly isInline!: boolean
get attrs() {
if (this.to) {
return { to: this.to }
}
if (this.href) {
return {
href: this.href,
target: '_blank',
rel: 'noopener noreferrer',
}
}
return {}
}
get tag() {
if (this.to) return 'NuxtLink'
return 'a'
}
get rel() {
if (this.href) return 'noopener noreferrer'
return null
}
get rootClasses() {
return [
this.isInline ? 'inline-flex' : 'flex',
Expand Down

0 comments on commit 6c3402a

Please sign in to comment.