2

我正在运行一个集成了 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 文件。同时,当我尝试创建一个新项目时,它没有被添加,也没有显示错误消息。

一切都像博客系列的魅力一样。

这是项目目录的样子:

项目目录

4

1 回答 1

1

没有可以用作标识符的字段。现在,您要么必须有一个名为“title”的字段,要么将“identifier_field”设置为您想要使用的字段的名称。该字段的值应该是唯一的条目,所以我猜想为每个项目添加一个“标题”可能是一个很好的举措。

这应该有一个错误,如果您可以在 GitHub 中打开一个错误,我们可以查看它。

于 2019-02-18T15:55:37.550 回答