Fix highlighting and get tag pages
This commit is contained in:
@@ -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
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user