forked from TryGhost/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
262 lines (251 loc) · 8.33 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
const postcssCustomMedia = require(`postcss-custom-media`)
const autoprefixer = require(`autoprefixer`)
const cssVariables = require(`postcss-css-variables`)
const colorModFunction = require(`postcss-color-mod-function`)
const cssNano = require(`cssnano`)
const customProperties = require(`postcss-custom-properties`)
const easyImport = require(`postcss-easy-import`)
const path = require(`path`)
const { isNil } = require('lodash')
require(`dotenv`).config({
path: `.env.${process.env.NODE_ENV}`,
})
const myAddedPlugin = (lunr) => (builder) => {
// removing stemmer
builder.pipeline.remove(lunr.stemmer)
builder.searchPipeline.remove(lunr.stemmer)
builder.metadataWhitelist = ['position']
// similarity tuning
builder.k1(0.75)
builder.b(0.5)
}
const SERVICE_WORKER_KILL_SWITCH = (process.env.SERVICE_WORKER_KILL_SWITCH === `true`) || false
const plugins = [
/**
* Content Plugins
*/
{
resolve: `gatsby-source-filesystem`,
options: {
path: path.join(__dirname,`content`, `biodynamo`, `demo`),
name: `compiled_notebooks`,
},
},
{
resolve: `gatsby-plugin-google-gtag`,
options: {
// You can add multiple tracking ids and a pageview event will be fired for all of them.
trackingIds: [
"G-KZH62X093T", // Google Analytics / GA
],
// This object is used for configuration specific to this plugin
pluginConfig: {
// Puts tracking script in the head instead of the body
head: true,
// Setting this parameter is also optional
//respectDNT: true,
// Avoids sending pageview hits from custom paths
//exclude: ["/preview/**", "/do-not-track/me/too/"],
},
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: path.join(__dirname, `content`),
name: `markdown-pages`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: path.join(__dirname, `src`, `images`),
name: `images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: path.join(__dirname, `public`),
name: `public`,
},
},
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
// https://www.gatsbyjs.com/plugins/gatsby-remark-images/
resolve: `gatsby-remark-images`,
options: {
withWebp: true,
showCaptions: ['title']
},
},
{
// https://www.gatsbyjs.com/plugins/gatsby-remark-copy-linked-files/
resolve: "gatsby-remark-copy-linked-files",
options: {
destinationDir: "static",
ignoreFileExtensions: [`png`, `jpg`, `jpeg`, `bmp`, `tiff`],
},
},
`gatsby-remark-autolink-headers`,
`gatsby-remark-code-titles`,
`gatsby-remark-prismjs`,
`gatsby-remark-external-links`,
`gatsby-remark-responsive-iframe`,
],
},
},
`gatsby-transformer-yaml`,
`gatsby-plugin-catch-links`,
/**
* Utility Plugins
*/
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `BioDynaMO`,
short_name: `bdm`,
start_url: `/`,
background_color: `#343f44`,
theme_color: `#343f44`,
display: `minimal-ui`,
icon: `static/images/bdm_logo.png`,
},
},
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-plugin-advanced-sitemap`,
options: {
query: `
{
allMarkdownRemark{
edges {
node {
id
frontmatter {
published_at: date
feature_image: image
}
fields {
slug
}
}
}
}
}`,
mapping: {
allMarkdownRemark: {
sitemap: `pages`,
},
},
exclude: [
`/dev-404-page`,
`/404`,
`/404.html`,
`/offline-plugin-app-shell-fallback`,
`/data-schema`,
`/data-schema-2`,
`/v0.11/README`,
`/README`,
/(\/)?hash-\S*/, // exclude internal tags
],
},
},
`gatsby-plugin-force-trailing-slashes`,
/**
* Display Plugins
*/
{
resolve: `gatsby-plugin-postcss`,
options: {
postCssPlugins: [
autoprefixer(),
easyImport(),
cssVariables(),
colorModFunction(),
customProperties({ preserve: false }),
postcssCustomMedia(),
cssNano({ zindex: false }),
],
},
},
{
resolve: `gatsby-plugin-react-svg`,
options: {
rule: {
include: /icons/,
},
},
},
/**
* Search Plugin
*/
{
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' }],
filterNodes: (node) => !isNil(node.frontmatter),
plugins: [myAddedPlugin]
}
],
// 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', store: true },
{ name: 'path', store: true },
{ name: 'sidebar', store: true },
{ name: 'headings' },
],
// 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,
description: node => node.frontmatter.meta_description,
content: node => node.rawMarkdownBody,
path: node => node.fields.slug,
sidebar: node => node.frontmatter.sidebar,
headings: node => node.headings,
},
},
//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'
// },
},
},
]
// Global switch to either use or remove service worker
if (SERVICE_WORKER_KILL_SWITCH) {
console.log(`Remove service worker plugin`)
plugins.push(`gatsby-plugin-remove-serviceworker`)
} else {
console.log(`Install service worker plugin`)
plugins.push(`gatsby-plugin-offline`)
}
module.exports = {
siteMetadata: {
title: `BioDynaMo Website`,
siteUrl: process.env.SITE_URL || `http://localhost:8000/`,
description: `Everything you need to know about agent-based simulations.`,
},
plugins: plugins,
flags: {
DEV_SSR: false
}
}