1

嗨,我正在使用gatsby-starter-netlify-cms并设置了一个名为“Bios”的辅助博客或添加内容管理器正确显示的新生物但是当我按下发布时它从未真正发布更改(绿线永远消失......)

控制台显示: “未捕获(承诺中)错误:集合必须具有一个有效条目标识符的字段名称,或者必须设置 identifier_field”

回购位于https://github.com/theMakersOrg/theMakersWebsiteV2

这是我的 config.yaml 中的代码

backend:
  name: git-gateway
  branch: master

media_folder: static/img
public_folder: /img

collections:
  - name: 'blog'
    label: 'Blog'
    folder: 'src/pages/blog'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    fields:
      - {
          label: 'Template Key',
          name: 'templateKey',
          widget: 'hidden',
          default: 'blog-post',
        }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Description', name: 'description', widget: 'text' }
      - { label: 'Body', name: 'body', widget: 'markdown' }
      - { label: 'Tags', name: 'tags', widget: 'list' }

  - name: 'bios'
    label: 'Bio'
    folder: 'src/pages/bios'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    fields:
      - {
          label: 'Template Key',
          name: 'templateKey',
          widget: 'hidden',
          default: 'bio-post',
        }
      - { label: 'Name', name: 'name', widget: 'string' }
      - { label: 'Publish Date', name: 'publishDate', widget: 'datetime' }
      - { label: 'Description', name: 'description', widget: 'text' }
      - { label: 'image', name: 'image1', widget: 'image' }
      - { label: 'Body', name: 'body', widget: 'markdown' }
      - { label: 'Tags', name: 'tags', widget: 'list' }

  - name: 'pages'
    label: 'Pages'
    files:
      - file: 'src/pages/about/index.md'
        label: 'About'
        name: 'about'
        fields:
          - {
              label: 'Template Key',
              name: 'templateKey',
              widget: 'hidden',
              default: 'about-page',
            }
          - { label: 'Title', name: 'title', widget: 'string' }
          - { label: 'Body', name: 'body', widget: 'markdown' }
      - file: 'src/pages/products/index.md'
        label: 'Products Page'
        name: 'products'
        fields:
          - {
              label: 'Template Key',
              name: 'templateKey',
              widget: 'hidden',
              default: 'product-page',
            }
          - { label: Title, name: title, widget: string }
          - { label: Image, name: image, widget: image }
          - { label: Heading, name: heading, widget: string }
          - { label: Description, name: description, widget: string }
          - {
              label: Intro,
              name: intro,
              widget: object,
              fields:
                [
                  { label: Heading, name: heading, widget: string },
                  { label: Description, name: description, widget: text },
                  {
                    label: Blurbs,
                    name: blurbs,
                    widget: list,
                    fields:
                      [
                        { label: Image, name: image, widget: image },
                        { label: Text, name: text, widget: text },
                      ],
                  },
                ],
            }
          - {
              label: Main,
              name: main,
              widget: object,
              fields:
                [
                  { label: Heading, name: heading, widget: string },
                  { label: Description, name: description, widget: text },
                  {
                    label: Image1,
                    name: image1,
                    widget: object,
                    fields:
                      [
                        { label: Image, name: image, widget: image },
                        { label: Alt, name: alt, widget: string },
                      ],
                  },
                  {
                    label: Image2,
                    name: image2,
                    widget: object,
                    fields:
                      [
                        { label: Image, name: image, widget: image },
                        { label: Alt, name: alt, widget: string },
                      ],
                  },
                  {
                    label: Image3,
                    name: image3,
                    widget: object,
                    fields:
                      [
                        { label: Image, name: image, widget: image },
                        { label: Alt, name: alt, widget: string },
                      ],
                  },
                ],
            }
          - {
              label: Testimonials,
              name: testimonials,
              widget: list,
              fields:
                [
                  { label: Quote, name: quote, widget: string },
                  { label: Author, name: author, widget: string },
                ],
            }
          - { label: Full_image, name: full_image, widget: image }
          - {
              label: Pricing,
              name: pricing,
              widget: object,
              fields:
                [
                  { label: Heading, name: heading, widget: string },
                  { label: Description, name: description, widget: string },
                  {
                    label: Plans,
                    name: plans,
                    widget: list,
                    fields:
                      [
                        { label: Plan, name: plan, widget: string },
                        { label: Price, name: price, widget: string },
                        {
                          label: Description,
                          name: description,
                          widget: string,
                        },
                        { label: Items, name: items, widget: list },
                      ],
                  },
                ],
            }
4

1 回答 1

3

注意:文件夹集合必须至少有一个名称为title的字段,用于创建新的条目 slug。该字段应使用默认字符串小部件。该字段的标签可以是任何字符串值。如果您希望使用不同的字段作为您的标识符,请将 identifier_field 设置为字段名称。

需要根据文档设置identifier_field

- name: 'bios'
label: 'Bio'
folder: 'src/pages/bios'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
format: 'frontmatter'
identifier_field: makerName
fields:
  - {
      label: 'Template Key',
      name: 'templateKey',
      widget: 'hidden',
      default: 'bio-post',
    }
  - { label: 'Maker Name', name: 'makerName', widget: 'string' }
  - { label: 'Publish Date', name: 'publishDate', widget: 'datetime' }
  - { label: 'Description', name: 'description', widget: 'text' }
  - { label: 'image', name: 'image1', widget: 'image' }
  - { label: 'Body', name: 'body', widget: 'markdown' }
  - { label: 'Tags', name: 'tags', widget: 'list' }
于 2018-12-11T23:23:17.223 回答