如何解决Netlify CMS 自定义预览问题危险地SetInnerHTML={{ __html: widgetFor('body') }} 在 /admin preview
我对这个组件有问题:
import CMS from 'netlify-cms-app'
import React from 'react'
import Article from './preview-templates/Article'
const ArticlePreview = ({ entry,widgetFor }) => {
console.log(widgetFor('body'),'body!!!!');
return (
<Article title={entry.getIn(['data','title'])} >
<div dangerouslySetInnerHTML={{ __html: widgetFor('body') }} />
</Article>
)
}
CMS.registerPreviewTemplate('Aktualnosci',ArticlePreview)
<div dangerouslySetInnerHTML={{ __html: widgetFor('body') }} />
在预览中给我 [object,Object] 而不是 Markdown 预览。
这是我的 config.yml:
backend:
name: git-gateway
branch: main # Branch to update (optional; defaults to master)
media_folder: static/img
public_folder: /img
collections:
- name: 'Aktualnosci'
label: 'Aktualnosci'
folder: 'src/pages/aktualnosci'
create: true
slug: '{{slug}}'
fields:
- {label: "Template Key",name: "templateKey",widget: "hidden",default: "post"}
- {label: "Tytuł",name: "title",widget: "string"}
- {label: "Data publikacji",name: "date",widget: "datetime"}
- {label: "Opis",name: "description",widget: "text"}
- {label: "Ujawnic posta?",name: "featuredpost",widget: "boolean"}
- {label: "Obrazek",name: "featuredimage",widget: image}
- {label: "Treśc calkowita",name: "body",widget: "markdown"}
- {label: "Tagi",name: "tags",widget: "list"}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。