text: let contentfulConfig
  
  try {
    // Load the Contentful config from the .contentful.json
    contentfulConfig = require('./.contentful')
  } catch (_) {}
  
  // Overwrite the Contentful config with environment variables if they exist
  contentfulConfig = {
    spaceId: process.env.CONTENTFUL_SPACE_ID || contentfulConfig.spaceId,
    accessToken:
      process.env.CONTENTFUL_DELIVERY_TOKEN || contentfulConfig.accessToken,
  }
  
  const { spaceId, accessToken } = contentfulConfig
  
  if (!spaceId || !accessToken) {
    throw new Error(
      'Contentful spaceId and the delivery token need to be provided.'
    )
  }
  
  module.exports = {
    siteMetadata: {
      title: "Howdy. I'm Amberley.",
    },
    plugins: [
      'gatsby-transformer-remark',
      'gatsby-plugin-react-helmet',
      {
        resolve: `gatsby-plugin-manifest`,
        options: {
          name: 'Amberley Dot Blog',
          short_name: 'amberleyblog',
          start_url: '/',
          background_color: '#f49985',
          theme_color: '#fff7f3',
          display: 'minimal-ui',
          icons: [
            {
              src: `/favicons/icon-192x192.png`,
              sizes: `192x192`,
              type: `image/png`,
            },
            {
              src: `/favicons/icon-512x512.png`,
              sizes: `512x512`,
              type: `image/png`,
            },
          ],
        },
      },
      'gatsby-plugin-offline',
      {
        resolve: `gatsby-plugin-typography`,
        options: {
          pathToConfigModule: `src/utils/typography.js`,
        },
      },
      {
        resolve: `gatsby-plugin-accessibilityjs`,
        options: {
          injectStyles: false,
          errorClassName: false,
        },
      },
      {
        resolve: `gatsby-plugin-google-analytics`,
        options: {
          trackingId: 'UA-112664995-1',
          anonymize: true,
        },
      },
      `gatsby-transformer-sharp`,
      `gatsby-plugin-sharp`,
      `gatsby-plugin-twitter`,
      {
        resolve: 'gatsby-source-contentful',
        options: contentfulConfig,
      },
    ],
  }
  