Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const StoryblokClient = require('storyblok-js-client')
const Storyblok = new StoryblokClient({
accessToken: 'YOUR_TOKEN'
})
Storyblok.setComponentResolver((component, blok) => {
switch(component) {
case 'my_button':
return `<button>${blok.button_text}</button>`
break;
case 'contact_form':
return `<a href="mailto:${blok.mail}">Mail me at: ${blok.mail}</a>`
break;
}
})
function createMarkup(storyblokHTML) {
return {
__html: Storyblok.richTextResolver.render(storyblokHTML),
}
}
const RichTextField = ({ data }) => {
return <div dangerouslySetInnerHTML={createMarkup(data)} />
}
export default RichTextField
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment