text: require('dotenv').config({
    path: `.env.${process.env.NODE_ENV}`,
  })
  
  const contentfulConfig = {
    spaceId: process.env.CONTENTFUL_SPACE_ID,
    accessToken:
      process.env.CONTENTFUL_ACCESS_TOKEN ||
      process.env.CONTENTFUL_DELIVERY_TOKEN,
  }
  
  // If you want to use the preview API please define
  // CONTENTFUL_HOST and CONTENTFUL_PREVIEW_ACCESS_TOKEN in your
  // environment config.
  //
  // CONTENTFUL_HOST should map to `preview.contentful.com`
  // CONTENTFUL_PREVIEW_ACCESS_TOKEN should map to your
  // Content Preview API token
  //
  // For more information around the Preview API check out the documentation at
  // https://www.contentful.com/developers/docs/references/content-preview-api/#/reference/spaces/space/get-a-space/console/js
  //
  // To change back to the normal CDA, remove the CONTENTFUL_HOST variable from your environment.
  if (process.env.CONTENTFUL_HOST) {
    contentfulConfig.host = process.env.CONTENTFUL_HOST
    contentfulConfig.accessToken = process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN
  }
  
  const { spaceId, accessToken } = contentfulConfig
  
  if (!spaceId || !accessToken) {
    throw new Error(
      'Contentful spaceId and the access token need to be provided.'
    )
  }
  
  module.exports = {
    siteMetadata: {
      title: '安装的小屋',
      description: 'aslkami的小屋',
    },
    pathPrefix: '/fate',
    plugins: [
      // 'gatsby-transformer-remark',
      {
        resolve: `gatsby-transformer-remark`,
        options: {
          plugins: [
            {
              resolve: `gatsby-remark-autolink-headers`,
              options: {
                offsetY: `100`,
                icon: `<svg aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>`,
                maintainCase: true,
                removeAccents: true,
                isIconAfterHeader: false,
                elements: [`h1`, `h2`, `h3`, `h4`, `h5`],
              },
            },
            {
              resolve: `gatsby-remark-highlight-code`,
            },
          ],
        },
      },
      'gatsby-transformer-sharp',
      'gatsby-plugin-react-helmet',
      'gatsby-plugin-sharp',
      'gatsby-plugin-image',
      {
        resolve: 'gatsby-source-contentful',
        options: contentfulConfig,
      },
      {
        resolve: `gatsby-plugin-manifest`,
        options: {
          name: '安装的小屋',
          short_name: '安装的小屋',
          start_url: '/',
          background_color: '#6b37bf',
          theme_color: '#6b37bf',
          // Enables "Add to Homescreen" prompt and disables browser UI (including back button)
          // see https://developers.google.com/web/fundamentals/web-app-manifest/#display
          display: 'standalone',
          icon: 'static/images/my-icon.jpg', // This path is relative to the root of the site.
          // An optional attribute which provides support for CORS check.
          // If you do not provide a crossOrigin option, it will skip CORS for manifest.
          // Any invalid keyword or empty string defaults to `anonymous`
          crossOrigin: `use-credentials`,
        },
      },
      {
        resolve: `gatsby-plugin-algolia`,
        options: {
          appId: process.env.GATSBY_ALGOLIA_APP_ID,
          apiKey: process.env.ALGOLIA_ADMIN_KEY,
          queries: require('./src/utils/algolia-queries'),
        },
      },
      `gatsby-plugin-styled-components`,
    ],
  }
  