WIP, psts in place, parsing mostly correclty
This commit is contained in:
43
gatsby-node.js
Normal file
43
gatsby-node.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const path = require(`path`);
|
||||
const { createFilePath } = require(`gatsby-source-filesystem`);
|
||||
|
||||
exports.onCreateNode = ({ node, getNode, actions }) => {
|
||||
const { createNodeField } = actions;
|
||||
|
||||
if (node.internal.type === `MarkdownRemark`) {
|
||||
var slug = createFilePath({ node, getNode, basePath: `pages` });
|
||||
createNodeField({
|
||||
node,
|
||||
name: `slug`,
|
||||
value: slug,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.createPages = async ({ graphql, actions }) => {
|
||||
const { createPage } = actions;
|
||||
|
||||
const result = await graphql(`
|
||||
query {
|
||||
allMarkdownRemark {
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
|
||||
createPage({
|
||||
path: node.fields.slug,
|
||||
component: path.resolve(`./src/templates/post.js`),
|
||||
context: {
|
||||
slug: node.fields.slug
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user