{"data":{"markdownRemark":{"html":"<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const path = require(&#39;path&#39;);\n\nexports.createPages = ({ boundActionCreators, graphql }) =&gt; {\n  const { createPage } = boundActionCreators;\n\n  const blogPostTemplate = path.resolve(`src/templates/post.js`);\n  return graphql(`{\n    allMarkdownRemark(\n      sort: { order: DESC, fields: [frontmatter___date] }\n      limit: 1000\n    ) {\n      edges {\n        node {\n          html\n          id\n          frontmatter {\n            date\n            path\n            title\n          }\n        }\n      }\n    }\n  }`)\n    .then(result =&gt; {\n      if (result.errors) {\n        return Promise.reject(result.errors)\n      }\n\n      const posts = result.data.allMarkdownRemark.edges;\n\n      // Create pages for each markdown file.\n      posts.forEach(({ node }, index) =&gt; {\n        createPage({\n          path: node.frontmatter.path,\n          component: blogPostTemplate,\n        });\n      });\n\n      return posts;\n    })\n};</code></pre></div>","excerpt":"","timeToRead":1,"frontmatter":{"date":"May 28, 2018","path":"/render-pages-from-markdown-sources","title":"Render pages from markdown sources"}},"relatedPosts":{"edges":[{"node":{"id":"5827a38e-604b-5150-801c-8503464bc574","frontmatter":{"title":"Add type field for markdown sources","path":"/add-type-field-for-markdown-sources","tags":["v1"]}}},{"node":{"id":"d2b7cd1f-bda7-5da1-8d51-23a38a68c0d4","frontmatter":{"title":"Pagination Plugin for GatsbyJS","path":"/gatsby-awesome-pagination","tags":["v1"]}}}]},"allCommentsJson":null,"allRatingsJson":null},"pageContext":{"tags":["v1"]}}