/** * Implement Gatsby's Node APIs in this file. * * See: https://www.gatsbyjs.org/docs/node-apis/ */ // You can delete this file if you're not using it const path = require('path') const { fmImagesToRelative } = require('gatsby-remark-relative-images') exports.onCreateNode = ({ node }) => { fmImagesToRelative(node) } exports.createPages = ({ actions, graphql }) => { const { createPage } = actions const template = path.resolve(`src/templates/doc-template.js`) return graphql(` { allMarkdownRemark( sort: { order: DESC, fields: [frontmatter___path] } limit: 1000 ) { edges { node { frontmatter { path } } } } } `).then(result => { if (result.errors) { return Promise.reject(result.errors) } result.data.allMarkdownRemark.edges.forEach(({ node }) => { createPage({ path: node.frontmatter.path || 'foo', component: template, }) }) }) }