Currently, HTMLSerializer is used by the RichText component (imported from prismic-reactjs library), where it accepts only the params: type, element, content, children, key. As per prismic-reactjs defined library, it is not possible to send an additional parameter in HTMLSerializer.
I discussed this with my colleague and we found that it's a bit tricky and can achieve this by passing extra information into an HTML Serializer. You can create a higher-order function: a function that returns another function. Then you just need to pass in the document type into your higher-order function.
const htmlSerializer = (doc) => {
return function (type, element, content, children) {
if (doc === "Blog") ...
}
}
Give this a try and let me know.
Thanks,
Priyanka
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
6
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.