我正在努力使我的头脑使用Netlify CMS与雨果ssg。
我用:
netlify-cms@1.0
hugo@0.29我有一个简单的netlify-cms config.yml,它有两个集合: posts和authors。
backend:
name: github
repo: sebhewelt/atlas
branch: master
display_url: https://mypage.com
publish_mode: editorial_workflow
media_folder: "static/uploads"
public_folder: "/uploads"
collections:
- label: "Posts"
name: "post"
folder: "content"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" , format: "YYYY-MM-DD hh:mma"}
- { label: "Body", name: "body", widget: "markdown" }
- label: "Authors"
name: "author"
folder: "data"
create: true
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}文档区分了两种集合类型,我假设应该选择文件集合,因为我希望将作者的数据保存在一个文件中。
我希望能够通过管理仪表板添加作者,并将其保存到数据文件夹中。docs没有提供一个示例,说明保存作者的文件应该是什么样子(或者cms是否自动生成它?)。
我在当前配置中遇到了一个错误。当我拯救“新作者”时,我得到了这样的信息:
未能持久化条目:错误:集合必须有一个有效的输入标识符的字段名
为什么我会有这个错误?
发布于 2017-12-09 16:45:37
您的作者文件需要位于顶级集合之下。此外,如果您希望能够向文件中添加多个作者,则需要在"list“类型小部件中包装"name”和"about“小部件。
示例:
collections:
- label: "Settings"
name: "settings"
files:
- name: "authors"
label: "Authors"
file: "data/authors.yml"
extension: "yml"
fields:
- label: "Author"
name: "author"
widget: "list"
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}用于文件集合的CMS文档:https://www.netlifycms.org/docs/collection-types/#file-collections
用于列表小部件的CMS文档:https://www.netlifycms.org/docs/widgets/#list
https://stackoverflow.com/questions/47730571
复制相似问题