首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让多个集合在Netlify-CMS中工作?

如何让多个集合在Netlify-CMS中工作?
EN

Stack Overflow用户
提问于 2019-02-18 18:34:11
回答 1查看 1.4K关注 0票数 2

我正在运行一个集成了Netlify-CMS的Gridsome项目。这是我的config.yml文件的样子:

代码语言:javascript
复制
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文件。同时,当我尝试创建一个新项目时,它不会被添加,也不会显示错误消息。

使用博客集合,一切工作起来都很有魅力。

项目目录如下所示:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-18 23:55:38

没有可用作标识符的字段。现在,您必须有一个名为"title“的字段,或者将"identifier_field"设置为您想要使用的字段的名称。字段的值对于条目来说应该是唯一的,所以我猜给每个项目添加一个"title“可能是个不错的选择。

这应该有一个错误,如果你可以在GitHub中打开一个bug,我们可以调查一下。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54745271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档