diff --git a/gatsby-node.js b/gatsby-node.js index bfe80bf..c622719 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -5,7 +5,7 @@ const select = require(`unist-util-select`) const fs = require(`fs-extra`) exports.createPages = ({ graphql, boundActionCreators }) => { - const { upsertPage } = boundActionCreators + const { createPage } = boundActionCreators return new Promise((resolve, reject) => { const pages = [] @@ -33,7 +33,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { // Create blog posts pages. _.each(result.data.allMarkdownRemark.edges, edge => { - upsertPage({ + createPage({ path: edge.node.fields.slug, // required component: blogPost, context: { @@ -47,15 +47,15 @@ exports.createPages = ({ graphql, boundActionCreators }) => { } // Add custom slug for blog posts to both File and MarkdownRemark nodes. -exports.onNodeCreate = ({ node, boundActionCreators, getNode }) => { - const { addFieldToNode } = boundActionCreators +exports.onCreateNode = ({ node, boundActionCreators, getNode }) => { + const { createNodeField } = boundActionCreators if (node.internal.type === `File`) { const parsedFilePath = path.parse(node.relativePath) const slug = `/${parsedFilePath.dir}/` - addFieldToNode({ node, fieldName: `slug`, fieldValue: slug }) + createNodeField({ node, fieldName: `slug`, fieldValue: slug }) } else if (node.internal.type === `MarkdownRemark`) { const fileNode = getNode(node.parent) - addFieldToNode({ + createNodeField({ node, fieldName: `slug`, fieldValue: fileNode.fields.slug,