我有一个现有的Gatsby / Prismic博客。我现在正尝试使用类别来组织我的内容。有谁知道一个好的教程?实际上,我已经找到了1个文档,但实际上并没有帮助。有谁知道使用盖茨比和Prismic创建和显示类别的步骤?
答案 0 :(得分:1)
在“ Prismic”中添加一个名为“ category”的“可重复类型”的新“ Content Type”。
要构建类别结构,可以使用右侧的“构建模式”或“ JSON编辑器”。如果选择“ JSON编辑器” 粘贴。
{
"Main" : {
"name" : {
"type" : "Text",
"config" : {
"label" : "name",
"placeholder" : "Name of the category"
}
}
}
}
...然后保存。
{
"Main" : {
//Here is your code for the blog post add the Meta below
"Meta" : {
"categories" : {
"type" : "Group",
"config" : {
"fields" : {
"category" : {
"type" : "Link",
"config" : {
"select" : "document",
"customtypes" : [ "category" ],
"label" : "category",
"placeholder" : "Category"
}
}
},
"label" : "Categories"
}
}
}
}
单击您也想添加类别的旧博客帖子。现在,在Main旁边应该有一个Meta标签。当您单击它时,您将看到有一个类别字段,当您单击该列表时会列出您创建的类别字段。选择一个。
现在,您可以按类别过滤博客文章。如何执行此操作取决于您自己,也许是查询以获取您放入下拉菜单中的所有类别名称? 盖茨比入门https://github.com/LekoArts/gatsby-starter-prismic-i18n