您好,我正在gatsby-starter-netlify-cms工作,并建立了一个名为“ Bios”的二级博客,我以该博客为模板,并使其从.md文件正确显示,问题是当我尝试更新或添加新的简历,内容管理器会正确显示,但是当我按“发布”时,它实际上从未发布过更改(绿线永远消失...)
控制台显示:“未捕获(承诺)错误:集合必须具有一个有效条目标识符的字段名,或者必须设置了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 },
],
},
],
}
答案 0 :(得分:2)
注意:文件夹集合必须至少具有一个名称为 title 的字段,才能创建新的条目条目。该字段应使用默认的字符串小部件。字段的标签可以是任何字符串值。如果您希望使用其他字段作为标识符,则将identifier_field设置为字段名称。
需要基于docs
设置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' }