内容丰富,难以理解富文本。我在this doc you can apply HTML to rich text中看到了options / rendernode。但是据我所知,您可以仅将其应用于他们的选择器,例如所有h1或列表或嵌入式资产块等。
我的设置是一个内容丰富的盖茨比博客,文章正文中包含丰富的文本。我想将一些图片/视频包装在fullwidth
类中。我可以用富文本格式吗?我该如何设置?
博客文章模板中的我的gatsby设置(简化文章):
const Work = props => {
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 alt={alt} src={url} />
}
},
},
}
return (
<Layout>
{documentToReactComponents(
props.data.contentfulWork.blurb.json,
options
)}
</Layout>
)
}