【发布时间】:2019-06-27 15:37:12
【问题描述】:
我正在使用 GatsbyJS,这是我第一次使用 react 和 graphql。我想混合单个页面的内容以同时包含“blog-post”类型内容和“repo-post”类型内容,但我不知道如何将其添加到查询中以对其进行过滤。
另外;我知道什么是frontmatter(re:markdown),但我不知道在这种情况下templateKey和“eq”是什么。我对我正在查看的内容了解得不够多,无法知道它被称为什么来开始寻找解释。
export const pageQuery = graphql`
query IndexQuery {
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] },
filter: { frontmatter: { templateKey: { eq: "blog-post" } }}
) {
edges {
node {
excerpt(pruneLength: 400)
id
fields {
slug
}
frontmatter {
title
templateKey
date(formatString: "MMMM DD, YYYY")
}
}
}
}
}
`
【问题讨论】: