UNPKG

pebblebed

Version:

Simplified interactions with Google Datastore for NodeJS

44 lines (39 loc) 1.02 kB
const path = require("path"); exports.createPages = ({ boundActionCreators, graphql }) => { const { createPage } = boundActionCreators; const docsTemplate = path.resolve(`src/templates/docsTemplate.js`); return graphql(` { allMarkdownRemark( sort: { order: DESC, fields: [frontmatter___order] } limit: 1000 ) { edges { node { excerpt(pruneLength: 250) html id frontmatter { order path title } } } } } `).then(result => { if (result.errors) { return Promise.reject(result.errors); } result.data.allMarkdownRemark.edges.forEach(({ node }) => { createPage({ path: node.frontmatter.path, component: docsTemplate, context: { path: node.frontmatter.path }, // additional data can be passed via context }); }); }); };