Skip to content

Commit

Permalink
fix: support internal links in ProseA (#342)
Browse files Browse the repository at this point in the history
Co-authored-by: Yaël Guilloux <yael.guilloux@gmail.com>
  • Loading branch information
farnabaz and Tahul authored May 27, 2021
1 parent 768ea9a commit f75419f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/defaultTheme/components/atoms/ProseA.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
<template>
<a>
<NuxtLink v-if="isInternal" :to="href">
<slot />
</NuxtLink>

<a v-else :href="href" v-bind="linkAttrs">
<slot />
</a>
</template>

<script>
import { computed, defineComponent } from '@nuxtjs/composition-api'
export default defineComponent({
props: {
href: {
type: String,
default: ''
},
blank: {
type: Boolean,
default: false
}
},
setup(props) {
const isInternal = computed(() => props.href.startsWith('/') && props.href.startsWith('//') === false)
const linkAttrs = computed(() => (props.blank ? { rel: 'noopener nofollow', target: '_blank' } : {}))
return {
isInternal,
linkAttrs
}
}
})
</script>

<style lang="postcss" scoped>
:not(h1, h2, h3) > a {
color: var(--primary-500);
Expand Down

1 comment on commit f75419f

@vercel
Copy link

@vercel vercel bot commented on f75419f May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.