diff --git a/gatsby-node.js b/gatsby-node.js index d10f09a..8496813 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,6 +1,7 @@ const _ = require("lodash") const Promise = require('bluebird') const path = require('path') +const { createFilePath } = require('gatsby-source-filesystem') exports.createPages = ({ graphql, boundActionCreators }) => { const { createPage } = boundActionCreators @@ -42,3 +43,16 @@ exports.createPages = ({ graphql, boundActionCreators }) => { ) }) } + +exports.onCreateNode = ({ node, boundActionCreators, getNode }) => { + const { createNodeField } = boundActionCreators + + if (node.internal.type === `MarkdownRemark`) { + const value = createFilePath({ node, getNode }) + createNodeField({ + name: `slug`, + node, + value, + }) + } +}