Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔍️ Do no overwrite href in NuxtLink with null #399

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading