【发布时间】:2021-05-13 02:42:31
【问题描述】:
我的索引页面显示带有图像和文本的简介。
但我无法将文本格式化为 HTML。我在 Netlify CMS 中使用 markdown-widget,并希望在管理视图中分隔内容时换行。
我也尝试过使用dangerouslySetInnerHTML={item.text},但没有任何运气。
item 只是所有简介的映射。
<p> {item.text} </p>
graphql:
markdownRemark(frontmatter: { templateKey: { eq: "index-page" } }) {
frontmatter {
intro {
blurbs {
image {
childImageSharp {
fluid(maxWidth: 2048, quality: 100) {
...GatsbyImageSharpFluid
}
}
}
heading
text
}
heading
description
}
}
}
}
config.yml 中的标签:
- {label: "Intro", name: "intro", widget: "object", fields: [{label: "Heading", name: "heading", widget: "string"}, {label: "Description", name: "description", widget: text}, {label: Blurbs, name: blurbs, widget: "list", fields: [{label: "Image", name: "image", widget: "image"}, {label: "Rubrik", name: "heading", widget: "string"}, {label: "Text", name: "text", widget: "markdown"}]}]}
我想从中读取的 Index.md(我想这是可行的,因为我得到了要显示的数据,而不是 html 形式)
blurbs:
- image: /img/img1.jpg
heading: heading one
text: >-
This is the content i want in HTML
- image: /img/img2.jpg
heading: heading two
text: >-
This is also the content i want in HTML
And this should give me a linebreak
【问题讨论】:
标签: html graphql markdown gatsby netlify-cms