forked from explosion/spaCy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
200 lines (191 loc) · 6.49 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
const autoprefixer = require('autoprefixer')
const path = require('path')
// https://florian.ec/blog/gatsby-build-netlify-segmentation-fault/
const sharp = require('sharp')
sharp.cache(false)
sharp.simd(false)
// Markdown plugins
const wrapSectionPlugin = require('./src/plugins/remark-wrap-section.js')
const customAttrsPlugin = require('./src/plugins/remark-custom-attrs.js')
const codeBlocksPlugin = require('./src/plugins/remark-code-blocks.js')
// Import metadata
const site = require('./meta/site.json')
const sidebars = require('./meta/sidebars.json')
const models = require('./meta/languages.json')
const universe = require('./meta/universe.json')
const DEFAULT_TEMPLATE = path.resolve('./src/templates/index.js')
const domain = process.env.BRANCH || site.domain
const siteUrl = `https://${domain}`
const isNightly = site.nightlyBranches.includes(domain)
const isLegacy = site.legacy || !!+process.env.SPACY_LEGACY
const favicon = `src/images/icon${isNightly ? '_nightly' : isLegacy ? '_legacy' : ''}.png`
const branch = isNightly ? 'develop' : 'master'
// Those variables are going to be replaced in the Markdown, e.g. %%GITHUB_SPACY
const replacements = {
GITHUB_SPACY: `https://github.com/explosion/spaCy/tree/${branch}`,
GITHUB_PROJECTS: `https://github.com/${site.projectsRepo}`,
SPACY_PKG_NAME: isNightly ? 'spacy-nightly' : 'spacy',
SPACY_PKG_FLAGS: isNightly ? ' --pre' : '',
}
/**
* Compute the overall total counts of models and languages
*/
function getCounts(langs = []) {
return {
langs: langs.length,
modelLangs: langs.filter(({ models }) => models && !!models.length).length,
models: langs.map(({ models }) => (models ? models.length : 0)).reduce((a, b) => a + b, 0),
}
}
module.exports = {
siteMetadata: {
...site,
sidebars,
...models,
counts: getCounts(models.languages),
universe,
nightly: isNightly,
legacy: isLegacy,
binderBranch: domain,
siteUrl,
},
plugins: [
{
resolve: `gatsby-plugin-sass`,
options: {
indentedSyntax: true,
postCssPlugins: [autoprefixer()],
cssLoaderOptions: {
localIdentName:
process.env.NODE_ENV == 'development'
? '[name]-[local]-[hash:8]'
: '[hash:8]',
},
},
},
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `docs`,
path: `${__dirname}/docs`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `docsImages`,
path: `${__dirname}/docs/images`,
},
},
{
resolve: 'gatsby-plugin-react-svg',
options: {
rule: {
include: /src\/images\/(.*)\.svg/,
},
},
},
{
resolve: `gatsby-mdx`,
options: {
root: __dirname,
extensions: ['.md', '.mdx'],
defaultLayouts: {
pages: DEFAULT_TEMPLATE,
},
mdPlugins: [customAttrsPlugin, wrapSectionPlugin, codeBlocksPlugin],
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-smartypants`,
options: {
backticks: false,
dashes: 'oldschool',
},
},
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 650,
linkImagesToOriginal: true,
sizeByPixelDensity: false,
showCaptions: true,
quality: 80,
withWebp: { quality: 80 },
wrapperStyle: { marginBottom: '20px' },
},
},
{
// NB: This need to run after gatsby-remark-images!
resolve: `gatsby-remark-unwrap-images`,
},
{
resolve: `gatsby-remark-copy-linked-files`,
},
{
resolve: 'gatsby-remark-find-replace',
options: {
replacements,
prefix: '%%',
},
},
],
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-catch-links`,
`gatsby-plugin-sitemap`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: site.title,
short_name: site.title,
start_url: `/`,
background_color: site.theme,
theme_color: site.theme,
display: `minimal-ui`,
icon: favicon,
},
},
{
resolve: `gatsby-plugin-plausible`,
options: { domain },
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
host: siteUrl,
sitemap: `${siteUrl}/sitemap.xml`,
// If we're in a special state (nightly, legacy) prevent indexing
resolveEnv: () => (isNightly ? 'development' : 'production'),
env: {
production: {
policy: [{ userAgent: '*', allow: '/' }],
},
development: {
policy: [
{ userAgent: '*', disallow: ['/'] },
{ userAgent: 'Twitterbot', allow: '/' },
],
},
},
},
},
`gatsby-plugin-offline`,
],
}