我正在尝试使用NetLify CMS与Hugo SSG一起绕头。
我使用:
netlify-cms@1.0
hugo@0.29
我有一个简单的netlify-cms config.yml,带有两个集合:帖子和作者。
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"}
文档区分了两种集合类型,我认为我应该选择文件集合,因为我想将作者数据存放在一个文件中。
我希望能够通过管理仪表板添加作者并将其保存到数据文件夹中。文档没有提供持有作者的文件的示例(或CMS会自动使其变成?)。
我在当前配置中遇到错误。当我保存"新作者"时,我会得到这个:
未能持续存在输入:错误:收集必须具有一个字段名称 是有效的输入标识符
为什么我会遇到此错误?
您的作者文件需要在顶级集合下。另外,如果您想能够在文件中添加多个作者,则需要将"名称"one_answers"关于窗口小部件"包装在"列表"键入窗口中。
示例:
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 for List小部件:https://www.netlifycms.org/docs/widgets/#list