I have a Nuxt project. I just updated all my dependencies and noticed some breaking changes moving to v4 of "@nuxtjs/prismic"
"@nuxtjs/prismic": "^4.0.1",
What seems to be affected are the <PrismicRichText /> blocks. I have added a wrapper div to all of them to keep my styling as it was since the default wrapper has been removed.
But I have a problem understanding what needs to be done to make the htmlSerializer work again. What I had was the following:
Just to clarify, you did the move from v3 -> v4? Is it just the htmlSerializer not working, are you getting any specific error related to it? The documentation for Vue v4 mentions this:
[PrismicRichText] You're using the deprecated version of <PrismicRichText> because either the serializer prop or the plugin richTextSerializer option were provided. This API will be removed in a future major.
If you have info on how to refactor this to be future proof, I would appreciate that.
Hi @leopold, sorry for the delay getting back to you!
With @prismicio/vue v5, we deprecated the old HTML-based serializer in favor of a more secure and flexible component-based serializer (no v-html) and flexible (component-based).
I noticed we had an issue with the link that should have been added to the warning you shared, I just published a fix.
Could you provide a slightly more advanced example, for example a hyperlink? I am wondering about the correct approach to extracting and working with the props from defineProps(getRichTextComponentProps()).
The following works, but is it the correct way? Also wondering about TS, since props.node can be many different types in this case.
We have hundreds of PrismicRichText in our projects and updating all of them to just add a new prop`` components` seems too much. Also adding one file per component is too much, since the component we require in the serializer are simple.
So using VueUse createReusableTemplate I created this:
So all the rich text related components stays in just one component. This is just a simple example if anyone is interested :)
Note: I could find the proper types for the RTNodeLabel as they are missing the field text. If you know a better way to type the props, please let me know, thank you!