Fix highlighting and get tag pages

This commit is contained in:
2020-09-30 17:06:54 -05:00
parent f32aee9342
commit 40f5df18b5
10 changed files with 82 additions and 16 deletions

View File

@@ -19,7 +19,7 @@ exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(`
query {
allMarkdownRemark {
postsRemark: allMarkdownRemark {
edges {
node {
fields {
@@ -28,10 +28,15 @@ exports.createPages = async ({ graphql, actions }) => {
}
}
}
tagsGroup: allMarkdownRemark {
group(field: frontmatter___tags) {
fieldValue
}
}
}
`);
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
result.data.postsRemark.edges.forEach(({ node }) => {
createPage({
path: node.fields.slug,
component: path.resolve(`./src/templates/post.js`),
@@ -40,4 +45,14 @@ exports.createPages = async ({ graphql, actions }) => {
}
});
});
result.data.tagsGroup.group.forEach((tag) => {
createPage({
path: `/tags/${tag.fieldValue}/`,
component: path.resolve(`./src/templates/tag.js`),
context: {
tag: tag.fieldValue
}
});
});
};