forked from mazipan/mazipan.space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
280 lines (278 loc) · 7.69 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
const path = require('path');
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
const SITE_NAME = process.env.SITE_NAME || '@mazipan';
const FULL_DOMAIN = process.env.FULL_DOMAIN || 'https://mazipan.space';
module.exports = {
siteMetadata: {
lang: 'id',
title: SITE_NAME,
description: 'A personal blog by mazipan',
siteUrl: FULL_DOMAIN,
},
mapping: {
'MarkdownRemark.frontmatter.author': 'AuthorYaml',
},
plugins: [
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'content',
path: path.join(__dirname, 'src', 'content'),
},
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-responsive-iframe',
options: {
wrapperStyle: 'margin-bottom: 1rem',
},
},
'gatsby-remark-prismjs',
'gatsby-remark-copy-linked-files',
'gatsby-remark-smartypants',
'gatsby-remark-abbr',
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 800,
quality: 50,
withWebp: true,
showCaptions: ['alt', 'title']
},
},
{
resolve: 'gatsby-remark-prismjs',
options: {
inlineCodeMarker: '÷',
},
},
{
resolve: "gatsby-remark-embed-gist",
options: {
username: 'mazipan',
includeDefaultCss: true
}
}
],
},
},
'gatsby-transformer-json',
{
resolve: 'gatsby-plugin-canonical-urls',
options: {
siteUrl: FULL_DOMAIN,
},
},
'gatsby-plugin-emotion',
'gatsby-plugin-typescript',
'gatsby-plugin-react-helmet',
'gatsby-transformer-yaml',
{
resolve: 'gatsby-plugin-postcss',
options: {
postCssPlugins: [require('postcss-color-function'), require('cssnano')()],
},
},
{
resolve: `gatsby-plugin-nprogress`,
options: {
// Setting a color is optional.
color: `tomato`,
// Disable the loading spinner.
showSpinner: true,
},
},
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: process.env.GA_KEY,
// Puts tracking script in the head instead of the body
head: true,
// IP anonymization for GDPR compliance
anonymize: true,
// Disable analytics for users with `Do Not Track` enabled
respectDNT: true,
// Avoids sending pageview hits from custom paths
pageTransitionDelay: 300,
// Specifies what percentage of users should be tracked
sampleRate: 100,
// Determines how often site speed tracking beacons will be sent
siteSpeedSampleRate: 100,
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `@mazipan`,
short_name: `@mazipan`,
start_url: `/`,
background_color: `#f4f8fb`,
theme_color: `#15171A`,
display: `standalone`,
icon: `src/static/icon.png`,
},
},
{
resolve: `gatsby-plugin-offline`,
options: {
precachePages: [`/about`, `/404`],
workboxConfig: {
importWorkboxFrom: `cdn`,
cacheId: `mazipan`,
// Don't cache-bust JS or CSS files, and anything in the static directory,
// since these files have unique URLs and their contents will never change
dontCacheBustURLsMatching: /(\.js$|\.css$|static\/)/,
runtimeCaching: [
{
// page-data.json files are not content hashed
urlPattern: /^https?:.*\page-data\/.*\/page-data\.json/,
handler: `NetworkFirst`,
},
{
// Use cacheFirst since these don't need to be revalidated (same RegExp
// and same reason as above)
urlPattern: /(\.js$|\.css$|static|images\/)/,
handler: `CacheFirst`,
},
{
urlPattern: /^https?:.*\.(js|json|css)$/,
handler: `StaleWhileRevalidate`,
},
{
urlPattern: /^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|woff|woff2)$/,
handler: `CacheFirst`,
},
{
urlPattern: /^https?:\/\/(api|fonts)\.googleapis\.com\/.*/,
handler: `CacheFirst`,
},
{
urlPattern: /^https?:\/\/github\.githubassets\.com\/.*/,
handler: `CacheFirst`,
},
{
urlPattern: /^https?:\/\/raw\.githubusercontent\.com\/.*/,
handler: `CacheFirst`,
},
],
skipWaiting: true,
clientsClaim: true,
}
},
},
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.excerpt,
date: edge.node.frontmatter.date,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
})
})
},
query: `
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] },
limit: 10
) {
edges {
node {
excerpt
html
fields { slug }
frontmatter {
title
date
}
}
}
}
}
`,
output: "/rss.xml",
title: "mazipan.space RSS Feed",
// optional configuration to insert feed reference in pages:
// if `string` is used, it will be used to create RegExp and then test if pathname of
// current page satisfied this regular expression;
// if not provided or `undefined`, all pages will have feed reference inserted
// match: "^/blog/",
},
],
},
},
{
resolve: 'gatsby-plugin-advanced-sitemap',
options: {
exclude: [
`/404`,
`/404.html`,
/(\/)?hash-\S*/,
],
createLinkInHead: true,
addUncaughtPages: true,
query: `
{
allAuthorYaml {
edges {
node {
id
slug
}
}
}
allTagYaml {
edges {
node {
id
slug
}
}
}
}
`,
mapping: {
allAuthorYaml: {
sitemap: `authors`,
},
allTagYaml: {
sitemap: `tags`,
}
},
}
},
// 'gatsby-plugin-netlify-cache',
// {
// resolve: "gatsby-plugin-webpack-bundle-analyser-v2",
// options: {
// analyzerMode: "static",
// defaultSizes: "gzip",
// openAnalyzer: false
// },
// },
],
};