require("dotenv-safe").config();
const queries = require("./src/utils/algolia.tsx");
const path = require("path");
const SITE_METADATA = require(path.resolve("./site-metadata.tsx"));

module.exports = {
  siteMetadata: SITE_METADATA,
  plugins: [
    "gatsby-plugin-robots-txt",
    `gatsby-plugin-netlify-cache`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-sass`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-typescript`,
    `gatsby-transformer-json`,
    `gatsby-transformer-sharp`,

    {
      resolve: "gatsby-plugin-algolia",
      options: {
        appId: process.env.GATSBY_ALGOLIA_APP_ID,
        apiKey: process.env.GATSBY_ALGOLIA_ADMIN_API_KEY,
        indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME,
        queries,
        chunkSize: 10000
      }
    },
    {
      resolve: "gatsby-plugin-compile-es6-packages",
      options: {
        modules: ["gatsby-theme-memoriestoriche"]
      }
    },
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        trackingId: SITE_METADATA.googleAnalyticsTrackingId,
        anonymize: false,
        respectDNT: false,
        variationId: 0
      }
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        background_color: `#fdfbfb`,
        display: `minimal-ui`,
        icon: `${__dirname}/src/images/favicon.png`,
        name: SITE_METADATA.title,
        short_name: SITE_METADATA.shortName,
        start_url: `/`,
        theme_color: SITE_METADATA.themeColor
      }
    },
    {
      resolve: "gatsby-plugin-matomo",
      options: {
        siteId: SITE_METADATA.piwikId,
        matomoUrl: "https://analytics.tubedatabase.co",
        siteUrl: SITE_METADATA.siteUrl
      }
    },
    {
      resolve: `gatsby-plugin-page-creator`,
      options: {
        path: `${__dirname}/src/pages`
      }
    },
    {
      resolve: `gatsby-plugin-polyfill-io`,
      options: {
        features: [`IntersectionObserver`]
      }
    },
    {
      resolve: "gatsby-plugin-sentry",
      options: {
        dsn: SITE_METADATA.sentryDns,
        environment: process.env.NODE_ENV,
        enabled: (() =>
          ["production", "stage"].indexOf(process.env.NODE_ENV) !== -1)()
      }
    },
    {
      resolve: `gatsby-plugin-sitemap`,
      options: {
        exclude: [
          `/*`,
          `/!it/*`,
          `/!en/*`,
          `/tags/*`,
          `/categorie/*`,
          `/en/categorie/*`,
          `/it/tags/*`
        ]
      }
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `favicon`,
        path: `${__dirname}/src/images`
      }
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `json`,
        path: `./data`,
        ignore: [`**/*.jpg`, `**/*.txt`]
      }
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `./data`,
        ignore: [`**/*.json`, `**/*.txt`]
      }
    },
    "gatsby-plugin-offline"
  ]
};
