首页 文章

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

提问于
浏览
0

我正在使用Gatsby Build 一个作品集站点 . 我的数据存储在markdown文件中,并使用graphql和gatsby-transformer-remark插件检索 . 我目前有3个文件,我可以在Graph QL查询中成功返回:
enter image description here

但是,当我尝试按类型过滤它时,我做错了什么:
enter image description here

非常感谢您的帮助 .

1 回答

  • 1

    我认为 filter 应该在 allMarkdownRemark 上:

    {
      allMarkdownRemark (
        filter: {
          frontmatter: { type: { eq: "folio" } }
        }
      ) {
        edges {
          node {
            frontmatter {
              title
              featured_image
              type
            }
          }
        }
      }
    }
    

相关问题