storyblok-rich-text-react-renderer
storyblok-rich-text-react-renderer copied to clipboard
Return promise within markResolvers
Hey!
I wonder if there is a way to return a promise with a custom markResolvers? In my case I would need to make an async within my [MARK_LINK] resolver but it seems like it's not possible right now?
Right now that's not possible i'm afraid, the API is designed to be synchronous. May i ask what your use case is?
Our Storyblok setup is a bit exotic which means that without using resolve_links=story (which I don't want to use right now) I am not able to find a localized version of the internal link within a rich text component. I have written a separate util function which makes a async call to fetch all details necessary but I can't use it within a markResolver as you just mentioned. I saw someone asking something similar on the Contentful alternative: https://github.com/contentful/rich-text/issues/83. I think I am going to use the same approach: process the document data before passing it to storyblok-rich-text-react-renderer
Yeah that'd be a solve. Otherwise, i guess i can make it work but that would require some significant changes and i'm not sure i'm prepared to do that, as i think most people are fine with it being sync
Yea I can imagine, for now it's fine. I asked copilot to generate me a transform function and it worked first time :D Now I can just pass my transformed document to the library.