I'm trying to recreate a text with small inline images inside.
I've set a content model in Contentful with a Rich Text but the only way I can insert the images is as a block.
Than in Gatsby I query the data:
const data = useStaticQuery(graphql`
query {
contentfulHomepage {
breaks {
id
shout {
json
}
}
}
}
`)
Here is the way I'm fetching the rich text with gatsby:
const options = {
renderNode: {
'embedded-asset-block': node => {
const alt = node.data.target.fields.title['en-US']
const url = node.data.target.fields.file['en-US'].url
return <img src={url} alt={alt} />
},
},
}
const breaks = data.contentfulHomepage.breaks.map(element => (
<Break
key={element.id}
shout={documentToReactComponents(element.shout.json, options)}
/>
))
I get the data correctly but the way the node is rendered is with several paragraph and images in between. Something like this:
<p>If you are </p>
<img alt...>
<p>already intrigued</p>
<img alt...>
...
Is there a way to get images as inline spans (or other) inside a paragraph block?
Something like:
<p>Some text<span><img></img></span> and other <span><img></img></span> text </p>
thanks