In this lesson we will prepare Tag browsing templates, and update gatsby-node.js
to use GraphQL to query for tags in our Markdown posts.
The posts forEach snippet within the transcript is not defined properly. It is correct in the video however.
posts.forEach(({node})) => {
if (node.frontmatter.tags.forEach(tag => {
if(!postByTag[tag]) {
postByTag[tag] = []
}
postsByTag[tag].push(node)
})
}
posts.forEach(({node}) => {
if (node.frontmatter.tags) {
node.frontmatter.tags.forEach(tag => {
if(!postsByTag[tag]) {
postsByTag[tag] = []
}
postsByTag[tag].push(node)
})
}
})