如何根据 markdown frontmatter 过滤 graph ql 查询?

Tim*_*mbo 1 markdown graphql gatsby

我正在使用 Gatsby 设置一个作品集网站。我的数据存储在 markdown 文件中,并使用 graphql 和 gatsby-transformer-remark 插件检索。我目前有 3 个文件,我可以在 Graph QL 查询中成功返回它们: 在此输入图像描述

但是,当我尝试按类型过滤它们时,我做错了: 在此输入图像描述

非常感谢您的帮助。

who*_*hat 6

我认为filter应该在allMarkdownRemark

{
  allMarkdownRemark (
    filter: {
      frontmatter: { type: { eq: "folio" } }
    }
  ) {
    edges {
      node {
        frontmatter {
          title
          featured_image
          type
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)