Merge pull request #70 from uptimeventures/generate-slug

fix(rss): generate slug for rss
This commit is contained in:
Kyle Mathews 2017-11-12 17:59:26 -08:00 committed by GitHub
commit 557555c0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
const _ = require("lodash") const _ = require("lodash")
const Promise = require('bluebird') const Promise = require('bluebird')
const path = require('path') const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
exports.createPages = ({ graphql, boundActionCreators }) => { exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = 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,
})
}
}