text: const path = require(`path`)
  const { createFilePath } = require(`gatsby-source-filesystem`)
  
  exports.onCreateNode = ({ node, getNode, actions }) => {
    const { createNodeField } = actions
    if (node.internal.type === `MarkdownRemark`) {
      const slug = createFilePath({ node, getNode, basePath: `pages` })
      createNodeField({
        node,
        name: `slug`,
        value: slug,
      })
    }
  }
  
  exports.createPages = async ({ graphql, actions }) => {
    const { createPage } = actions
    const result = await graphql(`
      query {
        allMarkdownRemark {
          edges {
            node {
              fields {
                slug
              }
              frontmatter {
                type
              }
            }
          }
        }
        wpgraphql {
          posts(first: 100) {
            nodes {
              id
              uri
            }
          }
        }
      }
    `)
  
    result.data.allMarkdownRemark.edges
      .filter(({ node }) => node.frontmatter.type === "blog")
      .forEach(({ node }) => {
        createPage({
          path: node.fields.slug,
          component: path.resolve(`./src/templates/blog-post.js`),
          context: {
            // Data passed to context is available
            // in page queries as GraphQL variables.
            slug: node.fields.slug,
          },
        })
      })
  
    result.data.allMarkdownRemark.edges
      .filter(({ node }) => node.frontmatter.type === "project")
      .forEach(({ node }) => {
        createPage({
          path: node.fields.slug,
          component: path.resolve(`./src/templates/project-template.js`),
          context: {
            // Data passed to context is available
            // in page queries as GraphQL variables.
            slug: node.fields.slug,
          },
        })
      })
  
    result.data.wpgraphql.posts.nodes.forEach(post => {
      actions.createPage({
        path: `old-blog/${post.uri}`,
        component: require.resolve("./src/templates/wp-post-template.js"),
        context: {
          id: post.id,
        },
      })
    })
  }
  