text: const { createFilePath } = require("gatsby-source-filesystem")
  const path = require("path")
  exports.onCreateNode = ({ node, getNode, actions }) => {
    const { createNodeField } = actions
    if (node.internal.type === "MarkdownRemark") {
      const slug = createFilePath({ node, getNode, basePath: "posts" })
      createNodeField({
        node,
        name: "slug",
        value: slug,
      })
    }
  }
  
  exports.createPages = ({ graphql, actions }) => {
    const { createPage } = actions
    return graphql(`
      query {
        allWordpressPost {
          nodes {
            slug
          }
        }
        allWordpressCategory {
          nodes {
            name
            id
            slug
          }
        }
        posts: allWordpressPost {
          edges {
            node {
              title
            }
          }
        }
      }
    `).then(results => {
      results.data.allWordpressPost.nodes.forEach(node => {
        createPage({
          path: node.slug,
          component: path.resolve(
            "./src/components/BlogPostLayout/BlogPostLayout.js"
          ),
          context: {
            slug: node.slug,
          },
        })
      })
     
      results.data.allWordpressCategory.nodes.forEach(node => {
        createPage({
          path: `category/${node.slug}`,
          component: path.resolve(
            "./src/components/CategoryPostLayout/CategoryPostLayout.js"
          ),
          context: {
            slug: node.slug,
          },
        })
      })
    })
  }
  