Open MetaBureau opened 2 years ago
@MetaBureau you probably figured this out by now, but in case someone else needs it this is how it is done:
Custom Block component with serializers:
<script setup>
import Link from '~/components/blocks/link.vue'
const props = defineProps({
blocks: Array,
})
const serializers = {
marks: {
link: Link,
},
}
</script>
<template>
<SanityContent :blocks="blocks" :serializers="serializers" />
</template>
Here is ~/components/blocks/link.vue
:
<template>
<NuxtLink target="_blank">
<slot />
</NuxtLink>
</template>
Reading here (https://sanity.nuxtjs.org/helpers/portable-text) I see:
Is anyone able to provide a simple example of opening links in a new window for Nuxt 3 please? I'm imagining something like: