如何让多个集合在 Netlify-CMS 中工作?
How to get multiple collections working within Netlify-CMS?
我是 运行 一个集成了 Netlify-CMS 的 Gridsome 项目。这是我的 config.yml 文件的样子:
backend:
name: github
branch: master # Branch to update (optional; defaults to master)
repo: user/repo
media_folder: "images/uploads"
public_folder: "/images/uploads"
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
folder: "blog" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
- name: "projects" # Used in routes, e.g., /admin/collections/blog
label: "Projects" # Used in the UI
folder: "projects" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Customer", name: "customer", widget: "string"}
- {label: "Activity", name: "activity", widget: "string"}
- {label: "Date", name: "date", widget: "datetime"}
- {label: "Link", name: "link", widget: "string"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
我可以在管理界面中同时看到博客和项目,但是,当我单击项目集合时,它不会在指定文件夹中显示我现有的 .md 文件。同时,当我尝试创建一个新项目时,它没有被添加,也没有显示错误信息。
博客集合的一切都像魅力一样。
项目目录如下所示:
没有可以作为标识符的字段。现在,您要么必须有一个名为 "title" 的字段,要么将 "identifier_field" 设置为您想要使用的字段名称。该字段的值对于条目应该是唯一的,所以我猜想为每个项目添加一个 "title" 可能是一个很好的举措。
这应该是一个错误,如果你可以在 GitHub 中打开一个错误,我们可以调查它。
我是 运行 一个集成了 Netlify-CMS 的 Gridsome 项目。这是我的 config.yml 文件的样子:
backend:
name: github
branch: master # Branch to update (optional; defaults to master)
repo: user/repo
media_folder: "images/uploads"
public_folder: "/images/uploads"
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
folder: "blog" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
- name: "projects" # Used in routes, e.g., /admin/collections/blog
label: "Projects" # Used in the UI
folder: "projects" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Customer", name: "customer", widget: "string"}
- {label: "Activity", name: "activity", widget: "string"}
- {label: "Date", name: "date", widget: "datetime"}
- {label: "Link", name: "link", widget: "string"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
我可以在管理界面中同时看到博客和项目,但是,当我单击项目集合时,它不会在指定文件夹中显示我现有的 .md 文件。同时,当我尝试创建一个新项目时,它没有被添加,也没有显示错误信息。
博客集合的一切都像魅力一样。
项目目录如下所示:
没有可以作为标识符的字段。现在,您要么必须有一个名为 "title" 的字段,要么将 "identifier_field" 设置为您想要使用的字段名称。该字段的值对于条目应该是唯一的,所以我猜想为每个项目添加一个 "title" 可能是一个很好的举措。
这应该是一个错误,如果你可以在 GitHub 中打开一个错误,我们可以调查它。