text: const path = require(`path`)
  const { createFilePath } = require(`gatsby-source-filesystem`)
  
  exports.createPages = async ({ graphql, actions }) => {
    const { createPage } = actions
  
    const blogPost = path.resolve(`./src/templates/blog-post.js`)
    const result = await graphql(
      `
        {
          allMarkdownRemark(
            sort: { fields: [frontmatter___date], order: DESC }
            limit: 1000
          ) {
            edges {
              node {
                fields {
                  slug
                }
                frontmatter {
                  title
                }
              }
            }
          }
        }
      `
    )
  
    if (result.errors) {
      throw result.errors
    }
  
    // Create blog posts pages.
    const posts = result.data.allMarkdownRemark.edges
  
    posts.forEach((post, index) => {
      const previous = index === posts.length - 1 ? null : posts[index + 1].node
      const next = index === 0 ? null : posts[index - 1].node
  
      createPage({
        path: post.node.fields.slug,
        component: blogPost,
        context: {
          slug: post.node.fields.slug,
          previous,
          next,
        },
      })
    })
  }
  
  exports.onCreateNode = ({ node, actions, getNode }) => {
    const { createNodeField } = actions
  
    if (node.internal.type === `MarkdownRemark`) {
      const value = createFilePath({ node, getNode })
      createNodeField({
        name: `slug`,
        node,
        value,
      })
    }
  }
  
  exports.onCreateWebpackConfig = ({ actions, loaders, getConfig }) => {
    const config = getConfig()
  
    config.module.rules = [
      // Omit the default rule where test === '\.jsx?$'
      ...config.module.rules.filter(
        rule => String(rule.test) !== String(/\.jsx?$/)
      ),
  
      // Recreate it with custom exclude filter
      {
        // Called without any arguments, `loaders.js()` will return an
        // object like:
        // {
        //   options: undefined,
        //   loader: '/path/to/node_modules/gatsby/dist/utils/babel-loader.js',
        // }
        // Unless you're replacing Babel with a different transpiler, you probably
        // want this so that Gatsby will apply its required Babel
        // presets/plugins.  This will also merge in your configuration from
        // `babel.config.js`.
        ...loaders.js(),
  
        test: /\.jsx?$/,
  
        // Exclude all node_modules from transpilation, except for 'swiper' and 'dom7'
        exclude: modulePath => !(/node_modules\/@tensorflow/.test(modulePath)),
      },
    ]
  
    // This will completely replace the webpack config with the modified object.
    actions.replaceWebpackConfig(config)
  }