generated from jpedroschmitz/gatsby-starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.ts
121 lines (114 loc) · 2.74 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import type { GatsbyConfig } from 'gatsby';
const path = require(`path`);
const { join } = require(`path`);
const { readdirSync, lstatSync } = require(`fs`);
require(`dotenv`).config({
path: `.env.${process.env.NODE_ENV}`,
});
const defaultLanguage = `en`;
const localesDirPath = join(__dirname, `locales`);
// based on the directories get the language codes
const languages = readdirSync(localesDirPath).filter((fileName: string) => {
const joinedPath = join(localesDirPath, fileName);
const isDirectory = lstatSync(joinedPath).isDirectory();
return isDirectory;
});
// defaultLanguage as first
languages.splice(languages.indexOf(defaultLanguage), 1);
languages.unshift(defaultLanguage);
const strapiConfig = {
apiURL: process.env.STRAPI_URL,
accessToken: process.env.STRAPI_TOKEN,
collectionTypes: [
{
singularName: `project`,
queryParams: {
locale: `all`,
},
},
{
singularName: `contact-link`,
},
{
singularName: `skill`,
queryParams: {
locale: `all`,
},
},
{
singularName: `section`,
queryParams: {
locale: `all`,
},
},
{
singularName: `project-link`,
},
],
singleTypes: [],
i18n: {
locale: `all`,
},
maxParallelRequests: 5,
remoteFileHeaders: {
Referer: process.env.APP_URL,
Authorization: `Bearer ${process.env.STRAPI_TOKEN}`,
},
};
const config: GatsbyConfig = {
flags: {
DEV_SSR: process.env.NODE_ENV === `development`,
FAST_DEV: process.env.NODE_ENV === `development`,
},
plugins: [
`gatsby-plugin-postcss`,
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
`gatsby-transformer-inline-svg`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `src`,
path: path.join(__dirname, `/src/`),
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `locale`,
path: path.join(__dirname, `/locales/`),
},
},
{
resolve: `gatsby-plugin-react-i18next`,
options: {
languages,
defaultLanguage,
siteUrl: process.env.APP_URL,
i18nextOptions: {
// debug: true,
fallbackLng: defaultLanguage,
supportedLngs: languages,
keySeparator: `.`, // necessary for nested translations
defaultNS: `common`,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
},
},
},
{
resolve: `gatsby-source-strapi`,
options: strapiConfig,
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [],
},
},
],
jsxRuntime: `automatic`,
};
export default config;