我使用gatsby和netlify-cms。 我的架构:
collections:
- name: "tags"
label: "Tags"
folder: "src/data/tags"
create: true
slug: "{{slug}}"
fields:
- {label: "Id", name: "title", widget: "string"}
- {label: "Description", name: "description", widget: "text"}
- name: "posts"
label: "Posts"
folder: "src/data/posts"
create: true
slug: "{{slug}}"
fields:
- {label: "Id", name: "title", widget: "string"}
- label: "Tags"
name: "tags"
widget: "list"
fields:
- label: "Tag"
name: "tag"
widget: "relation"
collection: "tags"
searchFields: ["name", "description"]
valueField: "title"
displayFields: ["name"]
我的查询:
query PostByID($id: String!) {
markdownRemark(id: { eq: $id }) {
id
html
frontmatter {
id: title
description
tags {
tag
// get tag description????
}
}
}
}
有没有办法获取标签说明?我正在尝试使用片段,但它不起作用。我在Gatsby GitHub上问了这个问题,我被告知这个例子:
fragment tagDetails on Tag {
title
description
}
并使用此用法:
tag {
...tagDetails
}
我收到此错误: “字段\”标记\“必须没有选择,因为类型\”字符串\“没有子字段。”