Reputation: 10117
I am using GatsbyJS and this is my first adventure with react and graphql. I am wanting to mix a single page's content to contain both "blog-post" type content, and "repo-post" type content, but I don't know how to add that to the query to filter for it.
Additionally; I know what frontmatter is (re: markdown), but I don't know what templateKey, and "eq" are in this context. I don't know enough about what I am looking at to know what it's called to start searching for an explanation.
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")
}
}
}
}
}
`
Upvotes: 0
Views: 12173
Reputation: 5742
eq
here means equals and templateKey
is just another key in your markdown frontmatter. You given filter is essentially saying "if the templateKey
's value in frontmatter
equals blog-post".
You can change the filter from
filter: { frontmatter: { templateKey: { eq: "blog-post" } }}
to
filter: { frontmatter: { templateKey: { in: ["blog-post", "repo-post"] } }}
You should check out the docs on graphql. It also has a great tool called GraphiQL to play around with queries.
Upvotes: 10