Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return promise within markResolvers #47

Open
Jdruwe opened this issue Mar 7, 2024 · 4 comments
Open

Return promise within markResolvers #47

Jdruwe opened this issue Mar 7, 2024 · 4 comments

Comments

@Jdruwe
Copy link

Jdruwe commented Mar 7, 2024

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?

@claus
Copy link
Owner

claus commented Mar 7, 2024

Right now that's not possible i'm afraid, the API is designed to be synchronous. May i ask what your use case is?

@Jdruwe
Copy link
Author

Jdruwe commented Mar 7, 2024

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: contentful/rich-text#83. I think I am going to use the same approach: process the document data before passing it to storyblok-rich-text-react-renderer

@claus
Copy link
Owner

claus commented Mar 7, 2024

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

@Jdruwe
Copy link
Author

Jdruwe commented Mar 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants