text: const path = require(`path`);
  
  exports.createPages = async ({ actions, graphql, reporter }) => {
    const { createPage } = actions;
  
    const blogPostTemplate = path.resolve(`src/templates/blogTemplate.js`);
  
    const result = await graphql(`
      {
        allMarkdownRemark(
          sort: { order: DESC, fields: [frontmatter___date] }
          limit: 1000
        ) {
          edges {
            node {
              id
              frontmatter {
                path
                mainCategory
              }
            }
          }
        }
      }
    `);
  
    if (result.errors) {
      reporter.panicOnBuild(`Error while running GraphQL query.`);
      return;
    }
  
    result.data.allMarkdownRemark.edges.forEach(({ node }) => {
      createPage({
        path: node.frontmatter.path || '',
        component: blogPostTemplate,
        context: {
          postUrl: node.frontmatter.path,
          category: node.frontmatter.mainCategory,
        },
      });
    });
  };
  