This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.ts
91 lines (86 loc) · 2.7 KB
/
gatsby-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// - Requires -
// - Imports -
import type { GatsbyConfig } from "gatsby";
import path from "path";
require(`@dotenvx/dotenvx`).config();
const i18n = require(`./src/helper/i18n/i18n`);
// - Variables -
if (process.env.SITE_URL === undefined) {
console.error(`SITE_URL is not defined. Issues may occur.`);
}
const { defaultLocale, Locale } = i18n;
const locales = Object.values(Locale);
const siteMetadata = {
title: `ssg starter`,
description: `A starter for static site generation with Gatsby`,
twitterUsername: `@username`,
siteUrl: process.env.SITE_URL,
};
// - Plugins -
const devPlugins = [`gatsby-plugin-tsconfig-paths`, `gatsby-plugin-postcss`];
const i18nPlugins = [
{
resolve: `gatsby-source-filesystem`,
options: {
path: path.resolve(__dirname, `locales`), // Path to the locales directory
name: `locale`,
},
},
{
// Enable i18n support
resolve: `gatsby-plugin-react-i18next`, // https://www.gatsbyjs.com/plugins/gatsby-plugin-react-i18next/
options: {
languages: locales,
defaultLanguage: defaultLocale,
siteUrl: siteMetadata.siteUrl,
redirect: true,
// generateDefaultLanguagePage: true, // Only generates a page for the default language but does not redirect
i18nextOptions: {
// debug: true,
fallbackLng: defaultLocale,
supportedLngs: locales,
defaultNS: `common`,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
keySeparator: `.`,
nsSeparator: `:`,
},
},
},
];
const seoPlugins = [
`gatsby-plugin-sitemap`,
`gatsby-plugin-robots-txt`,
{
// Generate favicons and icons for the site
resolve: `gatsby-plugin-manifest`, // https://www.gatsbyjs.com/plugins/gatsby-plugin-manifest/
options: {
// TODO: Update this to match your site
// name: "ssg starter",
// short_name: "ssg starter",
// start_url: "/",
// background_color: "#ffffff",
// theme_color: "#663399",
// display: "standalone",
icon: `assets/img/icon.png`, // necessary for develop to work
},
},
];
const analyticsPlugins = [
{
// Configures integration with Google Analytics
resolve: `gatsby-plugin-google-gtag`, // https://www.gatsbyjs.com/plugins/gatsby-plugin-google-gtag/
options: {
trackingIds: [`G-XXXXXXXXXX`], // TODO: Update this with your tracking ID
},
},
];
// - Config -
const config: GatsbyConfig = {
siteMetadata,
graphqlTypegen: true, // generates types for graphql queries
pathPrefix: `/ssg-starter`, // TODO: Update this to match your site
plugins: [...devPlugins, ...i18nPlugins, ...seoPlugins, ...analyticsPlugins],
};
export default config;