When using serializer.types, resolveComponent does not work and instead components have to be manually imported
See original GitHub issueVersion
module: 1.4.1 nuxt: 3-rc.11
When using the serializer, based on the docs, it seems the following should be possible:
<template>
<SanityContent :blocks="content" :serializers="serializers"/>
</template>
<script setup>
import { resolveComponent } from 'vue'
const props = defineProps({
content:{required:true,type:Array}
})
const serializers = {
types: {
youtube:resolveComponent('YoutubeVideo'),
gallery:resolveComponent('Gallery')
},
}
</script>
However, it returns the following error:
Failed to resolve component: Gallery
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
The only way I have managed to get this to work, is by importing the component manually, like so:
<template>
<SanityContent :blocks="content" :serializers="serializers"/>
</template>
<script setup>
import YoutubeVideo from '~/components/YoutubeVideo.vue'
import Gallery from '~/components/Gallery.vue'
const props = defineProps({
content:{required:true,type:Array}
})
const serializers = {
types: {
youtube:YoutubeVideo,
gallery:Gallery
},
marks: {
// You can also just pass a string for a custom serializer if it's an HTML element
internalLink: 'a'
}
}
</script>
Issue Analytics
- State:
- Created 10 months ago
- Comments:9
Top Results From Across the Web
Issues · nuxt-modules/sanity - GitHub
When using serializer.types, resolveComponent does not work and instead components have to be manually imported bug Something isn't working.
Read more >Serializers - Django REST framework - Tom Christie
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered...
Read more >Serializers - Django REST framework
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily ...
Read more >Define component schema with drf-spectacular for django API
As I am not using serializers, I am defining everything in the extend_schema decorator. Now my question is, if it is possible to...
Read more >Model Relationships in Django REST Framework - Corgibytes
There are three major kinds of relationship between database entries: ... Don't worry, Django knows how to work with this, so you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@danielroe would you mind keeping this issue open? At least @toddpadwick and me tried using the docs in their current form and ended up having problems, I suppose there’s some potential in being more clear on the different ways/use cases 😃
If Nuxt can’t know at build time which components you need, then you should mark them as global so they will all be built and available at runtime.