-
Notifications
You must be signed in to change notification settings - Fork 278
/
gatsby-config.js
307 lines (300 loc) · 9.09 KB
/
gatsby-config.js
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/* read the `.env.*` files, gatsby builtin */
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});
// const { isNil } = require('lodash');
// const mapPagesUrls = {
// index: '/',
// };
const siteMetadata = require('./config/siteMetadata');
module.exports = {
siteMetadata,
plugins: [
'gatsby-plugin-substrate',
/* Custom ESLint to your Gatsby dev environment */
{
resolve: 'gatsby-plugin-eslint',
options: {
stages: ['develop'],
options: {
emitWarning: true,
failOnError: true,
},
},
},
'gatsby-plugin-postcss',
/* use tailwindcss, used sass instead of css */
{
resolve: 'gatsby-plugin-sass',
options: {
postCssPlugins: [
require('tailwindcss'),
/* Load custom Tailwind CSS configuration, used to purge
"unused" tailwind classes */
require('./tailwind.config.js'),
],
},
},
/* removing registered legacy worker from gatsby-plugin-offline */
'gatsby-plugin-remove-serviceworker',
/* add seo headers and page titles, from pages/components */
'gatsby-plugin-react-helmet',
`gatsby-transformer-gitinfo`,
/* generate an application manifest.json */
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Substrate.io`,
short_name: `substrate.io`,
start_url: `/`,
background_color: `#24CC85`,
theme_color: `#24CC85`,
display: `minimal-ui`,
/* icon path is relative to the root of the site. */
icon: `src/images/favicon.png`,
},
},
/* source file system for (code based) icon images (svg) */
{
resolve: `gatsby-source-filesystem`,
options: {
name: `icons`,
path: `${__dirname}/src/images`,
},
},
/* Adds svg-react-loader to gatsby webpack config */
{
resolve: 'gatsby-plugin-react-svg',
options: {
rule: {
include: `${__dirname}/src/images/svg/`,
},
},
},
/* source file system for (cms) images/media/upload dir */
{
resolve: `gatsby-source-filesystem`,
options: {
name: `media`,
path: `${__dirname}/content/media`,
},
},
{
resolve: `gatsby-plugin-lunr`,
options: {
languages: [
// {
// // ISO 639-1 language codes. See https://lunrjs.com/guides/language_support.html for details
// name: 'en',
// // A function for filtering nodes. () => true by default
// filterNodes: node => node.frontmatter.lang === 'en',
// // Add to index custom entries, that are not actually extracted from gatsby nodes
// customEntries: [{ title: 'Pictures', content: 'awesome pictures', url: '/pictures' }],
// },
// {
// name: 'fr',
// filterNodes: node => node.frontmatter.lang === 'fr',
// },
],
// Fields to index. If store === true value will be stored in index file.
// Attributes for custom indexing logic. See https://lunrjs.com/docs/lunr.Builder.html for details
fields: [
{ name: 'title', store: true, attributes: { boost: 20 } },
{ name: 'content' },
{ name: 'url', store: true },
],
// 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,
content: node => node.rawMarkdownBody,
url: node => node.fields.url,
},
},
//custom index file name, default is search_index.json
filename: 'search_index.json',
//custom options on fetch api call for search_ındex.json
fetchOptions: {
credentials: 'same-origin',
},
},
},
/* work with images
- need to be after sourcing images
- docs: https://www.gatsbyjs.com/plugins/gatsby-plugin-image */
`gatsby-plugin-image`,
/* transform and get data from images */
`gatsby-plugin-sharp`,
/* querying for images used in dynamic components */
{
resolve: `gatsby-transformer-sharp`,
options: {
// The option defaults to true
checkSupportedExtensions: false,
},
},
/* allow to use relative path for images in markdown and frontmatter;
used to work with netlify-cms, loaded after the media themselves */
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: `gatsby-remark-autolink-headers`,
options: {
elements: [`h2`, `h3`],
},
},
'gatsby-remark-unwrap-images',
/* invoke lazyload manually to fix srcset rehype parsing
using lazysizes package (loaded in gatsby-browser.js) */
// `gatsby-remark-lazy-load`,
{
resolve: `gatsby-remark-embed-snippet`,
options: {
directory: `${__dirname}/content/code-snippets/`,
},
},
{
resolve: 'gatsby-remark-custom-blocks',
options: {
blocks: {
info: {
classes: 'info',
},
danger: {
classes: 'danger',
},
advice: {
classes: 'advice',
},
tabbedCode: {
classes: 'tabbedCode',
},
},
},
},
{
resolve: 'gatsby-remark-component',
/* for strict declaration (required to escape default components like <img />) */
options: { components: ['a', 'img'] },
},
{
resolve: `gatsby-remark-prismjs`,
options: {
aliases: {
sh: 'bash',
},
},
},
],
},
},
/* source file system for content dir */
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: `./content/md/`,
},
},
/* source the locales for gatsby-react-i18next */
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/content/locales`,
name: `locale`,
},
},
{
resolve: `gatsby-plugin-react-i18next`,
options: {
localeJsonSourceName: `locale`, // name given to `gatsby-source-filesystem` plugin.
languages: [`en`],
defaultLanguage: `en`,
// if you are using Helmet, you must include siteUrl
siteUrl: siteMetadata.siteUrl,
// you can pass any i18next options
// pass following options to allow message content as a key
i18nextOptions: {
fallbackLng: 'en',
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
keySeparator: false,
nsSeparator: false,
},
},
},
{
resolve: `gatsby-plugin-breadcrumb`,
options: {
// useAutoGen: required 'true' to use autogen
useAutoGen: true,
// autoGenHomeLabel: optional 'Home' is default
autoGenHomeLabel: `Home`,
// exclude: optional, include this array to exclude paths you don't want to
// generate breadcrumbs for (see below for details).
exclude: [`**/dev-404-page/**`, `**/404/**`, `**/404.html`, `**/offline-plugin-app-shell-fallback/**`],
// crumbLabelUpdates: optional, update specific crumbLabels in the path
crumbLabelUpdates: [],
},
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
output: `/sitemap.xml`,
createLinkInHead: true,
query: `
{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
}`,
resolveSiteUrl: ({ site }) => {
//Alternatively, you may also pass in an environment variable (or any location) at the beginning of your `gatsby-config.js`.
return site.siteMetadata.siteUrl;
},
serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => {
return {
url: `${site.siteMetadata.siteUrl}${node.path}`,
changefreq: `daily`,
priority: 0.7,
};
}),
},
},
{
resolve: 'gatsby-plugin-simple-analytics',
options: {
domain: 'apisa.substrate.io',
eventsGlobal: 'sa',
events: true,
trackPageViews: true,
},
},
{
resolve: `gatsby-plugin-force-trailing-slashes`,
options: {
excludedPaths: [`/404.html`],
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
host: 'https://docs.substrate.io',
sitemap: 'https://docs.substrate.io/sitemap.xml',
policy: [{ userAgent: '*', allow: '/' }],
},
},
],
};