text: const config = require('./config')
  
  const pathPrefix = config.pathPrefix === '/' ? '' : config.pathPrefix
  
  module.exports = {
    siteMetadata: {
      title: config.siteTitle,
      siteUrl: config.siteUrl,
      rssMetadata: {
        site_url: config.siteUrl + pathPrefix,
        feed_url: config.siteUrl + pathPrefix + config.siteRss,
        title: config.siteTitle,
        description: config.siteDescription,
        image_url: `${config.siteUrl + pathPrefix}/icons/icon-512x512.png`,
        author: config.userName,
        copyright: config.copyright,
      },
    },
    plugins: [
      {
        // keep as first gatsby-source-filesystem plugin for gatsby image support
        resolve: `gatsby-source-filesystem`,
        options: {
          path: `${__dirname}/static/img`,
          name: 'uploads',
        },
      },
      {
        resolve: `gatsby-source-filesystem`,
        options: {
          path: `${__dirname}/src/assets/img`,
          name: 'images',
        },
      },
      {
        resolve: `gatsby-source-filesystem`,
        options: {
          path: `${__dirname}/src/pages`,
          name: 'pages',
        },
      },
      {
        resolve: `gatsby-plugin-sitemap`,
      },
      `gatsby-transformer-sharp`,
      `gatsby-plugin-sharp`,
      {
        resolve: 'gatsby-transformer-remark',
        options: {
          plugins: [
            {
              resolve: `gatsby-remark-relative-images`,
            },
            {
              resolve: `gatsby-remark-images`,
              options: {
                // It's important to specify the maxWidth (in pixels) of
                // the content container as this plugin uses this as the
                // base for generating different widths of each image.
                maxWidth: 2048,
              },
            },
            `gatsby-remark-copy-linked-files`,
            {
              resolve: `gatsby-remark-prismjs`,
              options: {
                // Class prefix for <pre> tags containing syntax highlighting;
                // defaults to 'language-' (eg <pre class="language-js">).
                // If your site loads Prism into the browser at runtime,
                // (eg for use with libraries like react-live),
                // you may use this to prevent Prism from re-processing syntax.
                // This is an uncommon use-case though;
                // If you're unsure, it's best to use the default value.
                classPrefix: 'language-',
                // This is used to allow setting a language for inline code
                // (i.e. single backticks) by creating a separator.
                // This separator is a string and will do no white-space
                // stripping.
                // A suggested value for English speakers is the non-ascii
                // character '›'.
                inlineCodeMarker: null,
                // This lets you set up language aliases.  For example,
                // setting this to '{ sh: "bash" }' will let you use
                // the language "sh" which will highlight using the
                // bash highlighter.
                aliases: {},
                // This toggles the display of line numbers globally alongside the code.
                // To use it, add the following line in src/layouts/index.js
                // right after importing the prism color scheme:
                //  `require("prismjs/plugins/line-numbers/prism-line-numbers.css");`
                // Defaults to false.
                // If you wish to only show line numbers on certain code blocks,
                // leave false and use the {numberLines: true} syntax below
                showLineNumbersGlobal: false,
                // If setting this to true, the parser won't handle and highlight inline
                // code used in markdown i.e. single backtick code like `this`.
                noInlineHighlight: false,
              },
            },
          ],
        },
      },
      `gatsby-plugin-react-helmet`,
      `gatsby-plugin-sass`,
      {
        resolve: `gatsby-plugin-nprogress`,
        options: {
          color: config.themeColor,
          showSpinner: false,
        },
      },
      // Add your GTM Code to config file and uncomment this to activate Google Tag Manager
      // {
      //   resolve: `gatsby-plugin-google-tagmanager`,
      //   options: {
      //     id: config.googleTagManagerID,
      //     includeInDevelopment: false,
      //   },
      // },
      {
        resolve: `gatsby-plugin-manifest`,
        options: {
          name: config.siteTitle,
          short_name: config.siteTitleAlt,
          start_url: '/index.html',
          background_color: config.backgroundColor,
          theme_color: config.themeColor,
          display: 'standalone',
          icons: [
            {
              src: `/icons/icon-192x192.png`,
              sizes: `192x192`,
              type: `image/png`,
            },
            {
              src: `/icons/icon-512x512.png`,
              sizes: `512x512`,
              type: `image/png`,
            },
          ],
        },
      },
      `gatsby-plugin-offline`,
      {
        resolve: `gatsby-plugin-feed`,
        options: {
          setup (ref) {
            const ret = ref.query.site.siteMetadata.rssMetadata
            ret.allMarkdownRemark = ref.query.allMarkdownRemark
            ret.generator = 'The Leaky Cauldron Blog'
            return ret
          },
          query: `
                  {
                    site {
                      siteMetadata {
                        rssMetadata {
                          site_url
                          feed_url
                          title
                          description
                          image_url
                          author
                          copyright
                        }
                      }
                    }
                  }
                `,
          feeds: [
            {
              serialize (ctx) {
                const rssMetadata = ctx.query.site.siteMetadata.rssMetadata
                return ctx.query.allMarkdownRemark.edges
                  .filter(
                    edge => edge.node.frontmatter.templateKey === 'article-page'
                  )
                  .map(edge => ({
                    categories: edge.node.frontmatter.tags,
                    date: edge.node.frontmatter.date,
                    title: edge.node.frontmatter.title,
                    description: edge.node.excerpt,
                    author: rssMetadata.author,
                    url: rssMetadata.site_url + edge.node.fields.slug,
                    guid: rssMetadata.site_url + edge.node.fields.slug,
                    custom_elements: [{ 'content:encoded': edge.node.html }],
                  }))
              },
              query: `
                      {
                        allMarkdownRemark(
                          limit: 1000,
                          sort: { order: DESC, fields: [frontmatter___date] },
                        ) {
                          edges {
                            node {
                              excerpt(pruneLength: 400)
                              html
                              id
                              fields { slug }
                              frontmatter {
                                title
                                templateKey
                                cover {
                                  publicURL
                                }
                                date(formatString: "MMMM DD, YYYY")
                                tags
                              }
                            }
                          }
                        }
                      }
                    `,
              output: config.siteRss,
            },
          ],
        },
      },
      {
        resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
        options: {
          // Fields to index
          fields: [`title`, `tags`],
          // How to resolve each field`s value for a supported node type
          resolvers: {
            // For any node of type MarkdownRemark, list how to resolve the fields` values
            MarkdownRemark: {
              title: node => node.frontmatter.title,
              tags: node => node.frontmatter.tags,
              slug: node => node.fields.slug,
              templateKey: node => node.frontmatter.templateKey,
            },
          },
        },
      },
      {
        resolve: `gatsby-plugin-netlify-cms`,
        options: {
          modulePath: `${__dirname}/src/cms/cms.js`,
          enableIdentityWidget: true,
          htmlTitle: `TLCB Content Manager`,
        },
      },
      `gatsby-plugin-netlify`,
    ],
  }
  