Skip to content

Commit

Permalink
Merge pull request #10 from eggheadio/ij/update-templates-query
Browse files Browse the repository at this point in the history
Update Blog page allMdx query
  • Loading branch information
theianjones authored Sep 10, 2019
2 parents 33d183d + 3ddde64 commit fbd1ec6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/gatsby-theme-egghead-blog/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,11 @@ exports.onCreateNode = ({ node, getNode, actions }) => {
node,
value: node.frontmatter.redirects,
})

createNodeField({
name: 'isPost',
node,
value: true,
})
}
}
13 changes: 5 additions & 8 deletions packages/gatsby-theme-egghead-blog/src/templates/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const Blog = ({
.map(id =>
allMdx.edges.find(
edge =>
edge.node.id === id &&
edge.node.parent.sourceInstanceName !== 'pages',
edge.node.id === id
),
)
.filter(post => post !== undefined)
Expand Down Expand Up @@ -131,7 +130,10 @@ export const pageQuery = graphql`
site {
...site
}
allMdx(sort: { fields: [frontmatter___date], order: DESC }) {
allMdx(
sort: { fields: [frontmatter___date], order: DESC }
filter: { fields: { isPost: { eq: true } } }
) {
edges {
node {
excerpt(pruneLength: 300)
Expand All @@ -141,11 +143,6 @@ export const pageQuery = graphql`
slug
date
}
parent {
... on File {
sourceInstanceName
}
}
frontmatter {
title
date(formatString: "MMMM DD, YYYY")
Expand Down

0 comments on commit fbd1ec6

Please sign in to comment.