-
-
Save jeremeylduvall/d7ea26b1b79fa2f986688100a02a60ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require(`lodash`) | |
const Promise = require(`bluebird`) | |
const path = require(`path`) | |
const slash = require(`slash`) | |
exports.createPages = ( { graphql, boundActionCreators } ) => { | |
const { createPage } = boundActionCreators; | |
return new Promise( ( resolve, reject ) => { | |
graphql( | |
` | |
{ | |
allWordpressPost { | |
edges { | |
node { | |
date( formatString: "YYYY/MM/DD/" ) | |
slug | |
} | |
} | |
} | |
} | |
` | |
).then( result => { | |
if (result.errors) { | |
console.log(result.errors) | |
reject(result.errors) | |
} | |
const template = path.resolve(`./src/templates/single-photo.js`); | |
_.each( result.data.allWordpressPost.edges, edge => { | |
createPage( { | |
path: edge.node.date + edge.node.slug, | |
component: slash( template ), | |
context: { | |
slug: edge.node.slug | |
}, | |
} ) | |
} ) | |
} ) | |
resolve(); | |
} ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment