text: const path = require("path")
  
  // Generate a slug for markdown files
  // module.exports.onCreateNode = ({ node, actions }) => {
  //   const { createNodeField } = actions
  
  //   if (node.internal.type === "MarkdownRemark") {
  //     const slug = path.basename(node.fileAbsolutePath, ".md")
  
  //     createNodeField({
  //       node,
  //       name: "slug",
  //       value: slug,
  //     })
  //   }
  // }
  
  // Create a page from markdown files with slug above
  module.exports.createPages = async ({ graphql, actions }) => {
    const { createPage } = actions
  
    // 1. Get path to template
    const blogTemplate = path.resolve("./src/templates/blog.js")
    // 2. Get markdown data
    // const res = await graphql(`
    //   query {
    //     allMarkdownRemark {
    //       edges {
    //         node {
    //           fields {
    //             slug
    //           }
    //         }
    //       }
    //     }
    //   }
    // `)
    // 2. Get Contentful data
    const res = await graphql(`
      query {
        allContentfulBlogPost {
          edges {
            node {
              slug
            }
          }
        }
      }
    `)
    // 3. Create new pages
    res.data.allContentfulBlogPost.edges.forEach(edge => {
      createPage({
        component: blogTemplate,
        path: `/blog/${edge.node.slug}`,
        context: {
          slug: edge.node.slug,
        },
      })
    })
  }
  