Skip to content

Instantly share code, notes, and snippets.

@christiannwamba
Created January 30, 2018 14:58
Show Gist options
  • Save christiannwamba/0e9ddb4a365199440f406c331865691a to your computer and use it in GitHub Desktop.
Save christiannwamba/0e9ddb4a365199440f406c331865691a to your computer and use it in GitHub Desktop.
exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
graphql(`
{
allMarkdownRemark {
edges {
node {
fields {
slug
}
}
}
}
}
`).then(result => {
result.data.allMarkdownRemark.edges.map(({ node }) => {
createPage({
path: node.fields.slug,
component: path.resolve(`./src/templates/blog-post.js`),
context: {
slug: node.fields.slug,
},
})
})
resolve()
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment