This repository has been archived by the owner on Jun 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-config.js
303 lines (273 loc) · 8.08 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
require('ts-node').register();
const LOCALES = ['en', 'ja'];
module.exports = {
siteMetadata: {
siteUrl: 'https://kagamine.dev',
repoUrl: 'https://github.com/maxkagamine/kagamine.dev'
},
plugins: [
// SSR for helmet (at top to put meta tags above everything else)
'gatsby-plugin-react-helmet',
// Not a PWA, but create a manifest anyway in the off chance someone adds
// this to their homescreen
{
resolve: 'gatsby-plugin-manifest',
options: {
...LOCALES.reduce((options, locale, i) => {
let localeOptions = {
name: require(`./src/messages/${locale}.json`).name,
lang: locale,
start_url: `/${locale}/`
};
if (i == 0) {
Object.assign(options, localeOptions);
} else {
options.localize.push(localeOptions);
}
return options;
}, { localize: [] }),
display: 'standalone',
theme_color: '#fdd002',
background_color: '#fdd002',
include_favicon: false, // Using round favicon for tabs
theme_color_in_head: false,
legacy: false,
cache_busting_mode: 'name',
icon: 'src/images/profile.png',
icon_options: {
purpose: 'maskable'
}
}
},
// Generate favicon.ico, same as manifest icon but cropped to circle
{
resolve: 'favicon-ico',
options: {
icon: 'src/images/profile.png',
shape: 'circle'
}
},
// Configure firebase & set up analytics
{
resolve: 'firebase-init',
options: {
firebaseConfig: {
apiKey: 'AIzaSyDtssZS3bpqvZLMsKM9mBWMxvGxJ1JlQO4',
authDomain: 'kagamine-dev.firebaseapp.com',
databaseURL: 'https://kagamine-dev.firebaseio.com',
projectId: 'kagamine-dev',
storageBucket: 'kagamine-dev.appspot.com',
messagingSenderId: '82879755365',
appId: '1:82879755365:web:d5d51ac04d1df7fc1c428c'
// measurementId: 'G-E3767BNKVB'
},
measurementId: 'G-39LC601E4K',
domain: 'kagamine.dev',
vapidKey: 'BD_wHrdYAmd5GUysYbM69y3QnjqIF4oA2hw1oA1xZPwActCSy3x5mPg35MUzuS0HladBbhMxIFZcW-CoP8_HhEI'
}
},
// Compile service worker
{
resolve: 'service-worker',
options: {
entry: `${__dirname}/src/workers/firebase-messaging-sw.ts`
}
},
// Set up image preprocessing
'gatsby-transformer-sharp',
{
resolve: 'gatsby-plugin-sharp',
options: {
useMozJpeg: true,
defaultQuality: 80
}
},
// Load files in pages & images directories
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'pages',
path: `${__dirname}/src/pages`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images`
}
},
// Process markdown files
{
resolve: 'gatsby-transformer-remark',
options: {
excerpt_separator: '<!-- end -->',
pedantic: false, // "pedantic" = pre-commonmark broken parsing
plugins: [
// Auto smart quotes, em dashes, and ellipses
'gatsby-remark-smartypants',
// Add target & rel to external links
{
resolve: 'gatsby-remark-external-links',
options: {
rel: 'noopener noreferrer'
}
},
// Add anchors to headers
'gatsby-remark-autolink-headers',
// Syntax highlighting
{
resolve: 'gatsby-remark-vscode',
options: {
theme: ({ language }) => {
if (['cs', 'csharp', 'c#'].includes(language)) {
return 'Default Dark+';
}
return 'One Dark Pro';
},
extensions: ['onedark-pro'],
languageAliases: {
shell: 'sh'
}
}
},
// Copy referenced files/media to public dir
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
ignoreFileExtensions: [] // Remove if using gatsby-remark-images
}
},
// Embed YouTube videos, tweets, etc.
// NOTE: Using forked version of plugin due to necessary bug fixes
{
resolve: '@raae/gatsby-remark-oembed',
options: {
providers: {
usePrefix: false,
include: ['YouTube', 'GIPHY'] // Whitelisting as some add js to page even if not used
}
}
},
// Make YouTube embeds 100% width while maintaining aspect ratio
'gatsby-remark-responsive-iframe'
]
}
},
// Configure Material-UI (this comes before localized-blog so that the
// latter will wrap it with the intl provider)
'material-ui-theme',
// Create localized pages & set up react-intl
{
resolve: 'localized-blog',
options: {
locales: LOCALES,
messages: `${__dirname}/src/messages`,
blogPostTemplate: `${__dirname}/src/pages/_blog-post.tsx`
}
},
// Add cover images to blog posts
'cover-images',
// Use git log to show last updated date
'git-last-updated',
// Client-side routing for <a> tags in markdown posts
'gatsby-plugin-catch-links',
// Load script for tweet buttons & twitter embeds
'gatsby-plugin-twitter',
// Create rss feed
{
resolve: 'gatsby-plugin-feed',
options: {
query: `
{
site {
siteMetadata {
siteUrl
}
}
}
`,
feeds: LOCALES.map(locale => ({
query: `
{
allMarkdownRemark(
filter: { fields: { locale: { eq: "${locale}" } } },
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
node {
fields {
slug
}
frontmatter {
title
date
}
excerpt(format: PLAIN)
}
}
}
}
`,
setup({ query: { site }, ...rest }) {
return {
...rest,
site_url: `${site.siteMetadata.siteUrl}/${locale}/`
};
},
serialize({ query: { site, allMarkdownRemark } }) {
return allMarkdownRemark.edges.map(({ node }) => ({
title: node.frontmatter.title,
description: node.excerpt,
date: node.frontmatter.date,
url: `${site.siteMetadata.siteUrl}${node.fields.slug}`
}));
},
title: require(`./src/messages/${locale}.json`).name,
output: `/${locale}/feed.xml`,
match: `^/${locale}/`
}))
}
},
// Create sitemap
{
resolve: 'gatsby-plugin-sitemap',
options: {
exclude: ['/*/404.html']
}
},
// Create robots.txt (to prevent weird image results)
{
resolve: 'gatsby-plugin-robots-txt',
options: {
policy: [{ userAgent: 'Googlebot-Image', disallow: '/' }]
}
},
// Generate types for graphql queries
{
resolve: 'gatsby-plugin-typegen',
options: {
// Syntax highlighting & intellisense via vscode Apollo GraphQL extension
emitSchema: {
'src/__generated__/gatsby-introspection.json': true
},
emitPluginDocuments: {
'src/__generated__/gatsby-plugin-documents.graphql': true
}
}
},
// Perform linting during webpack builds
{
resolve: 'gatsby-plugin-eslint',
options: {
test: /\.[jt]sx?$/
}
},
// Perform type checking during webpack builds
'gatsby-plugin-typescript-checker',
// SSR for Material-UI's JSS styles
'gatsby-plugin-material-ui',
// Post-build shenanigans
'ascii-art'
]
};