forked from EnterpriseDB/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
411 lines (395 loc) · 11.6 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
});
const gracefulFs = require("graceful-fs");
const algoliaTransformer = require("./src/constants/algolia-indexing.js");
const { replacePathVersion } = require("./src/constants/gatsby-utils.js");
const ANSI_BLUE = "\033[34m";
const ANSI_GREEN = "\033[32m";
const ANSI_STOP = "\033[0m";
const isBuild = process.env.NODE_ENV === "production";
const isProduction = process.env.APP_ENV === "production";
const algoliaIndex = process.env.ALGOLIA_INDEX_NAME || "edb-docs-staging";
/******** Sourcing *********/
const sourceFilename = isBuild ? "build-sources.json" : "dev-sources.json";
const sourceToPluginConfig = {
bart: { name: "bart", path: "product_docs/docs/bart" },
biganimal: { name: "biganimal", path: "product_docs/docs/biganimal" },
postgres_for_kubernetes: {
name: "postgres_for_kubernetes",
path: "product_docs/docs/postgres_for_kubernetes",
},
postgres_distributed_for_kubernetes: {
name: "postgres_distributed_for_kubernetes",
path: "product_docs/docs/postgres_distributed_for_kubernetes",
},
edb_plus: { name: "edb_plus", path: "product_docs/docs/edb_plus" },
efm: { name: "efm", path: "product_docs/docs/efm" },
epas: { name: "epas", path: "product_docs/docs/epas" },
pgd: { name: "pgd", path: "product_docs/docs/pgd" },
pge: { name: "pge", path: "product_docs/docs/pge" },
eprs: { name: "eprs", path: "product_docs/docs/eprs" },
hadoop_data_adapter: {
name: "hadoop_data_adapter",
path: "product_docs/docs/hadoop_data_adapter",
},
jdbc_connector: {
name: "jdbc_connector",
path: "product_docs/docs/jdbc_connector",
},
language_pack: {
name: "language_pack",
path: "product_docs/docs/language_pack",
},
lasso: {
name: "lasso",
path: "product_docs/docs/lasso",
},
livecompare: {
name: "livecompare",
path: "product_docs/docs/livecompare",
},
migration_portal: {
name: "migration_portal",
path: "product_docs/docs/migration_portal",
},
migration_toolkit: {
name: "migration_toolkit",
path: "product_docs/docs/migration_toolkit",
},
mysql_data_adapter: {
name: "mysql_data_adapter",
path: "product_docs/docs/mysql_data_adapter",
},
mongo_data_adapter: {
name: "mongo_data_adapter",
path: "product_docs/docs/mongo_data_adapter",
},
net_connector: {
name: "net_connector",
path: "product_docs/docs/net_connector",
},
ocl_connector: {
name: "ocl_connector",
path: "product_docs/docs/ocl_connector",
},
odbc_connector: {
name: "odbc_connector",
path: "product_docs/docs/odbc_connector",
},
pem: { name: "pem", path: "product_docs/docs/pem" },
pgbouncer: { name: "pgbouncer", path: "product_docs/docs/pgbouncer" },
pg_extensions: {
name: "pg_extensions",
path: "advocacy_docs/pg_extensions",
},
CloudNativePG: {
name: "CloudNativePG",
path: "advocacy_docs/supported-open-source/cloud_native_pg",
},
pgpool: { name: "pgpool", path: "product_docs/docs/pgpool" },
postgis: { name: "postgis", path: "product_docs/docs/postgis" },
pwr: { name: "pwr", path: "product_docs/docs/pwr" },
repmgr: { name: "repmgr", path: "product_docs/docs/repmgr" },
slony: { name: "slony", path: "product_docs/docs/slony" },
tde: { name: "tde", path: "product_docs/docs/tde" },
tpa: { name: "tpa", path: "product_docs/docs/tpa" },
wait_states: {
name: "wait_states",
path: "advocacy_docs/pg_extensions/wait_states",
},
};
const externalSourcePlugins = () => {
const sourcePlugins = [];
// default to full set of sources
let sources = Object.keys(sourceToPluginConfig).reduce((result, source) => {
result[source] = true;
return result;
}, {});
if (gracefulFs.existsSync(sourceFilename)) {
console.log(
`${ANSI_BLUE}###### Sourcing from ${sourceFilename} #######${ANSI_STOP}`,
);
console.log(
`${ANSI_GREEN}Note: ${sourceFilename} is no longer required; delete it to load the full set of docs.${ANSI_STOP}`,
);
sources = JSON.parse(gracefulFs.readFileSync(sourceFilename));
}
for (const [source, enabled] of Object.entries(sources)) {
const config = sourceToPluginConfig[source];
if (enabled && config) {
sourcePlugins.push({
resolve: "gatsby-source-filesystem",
options: {
name: config.name,
path: config.path,
},
});
}
}
return sourcePlugins;
};
/******** Algolia Index ********/
const indexQuery = `
{
allMdx {
nodes {
frontmatter {
title
product
platform
tags
directoryDefaults {
product
platform
}
}
id
fields {
docType
product
path
version
}
mdxAST
}
}
}
`;
/********** Gatsby config *********/
module.exports = {
pathPrefix: "/docs",
siteMetadata: {
title: "EDB Docs",
baseUrl: "https://www.enterprisedb.com/docs",
imageUrl: "https://www.enterprisedb.com/docs/images/social.jpg",
siteUrl: "https://www.enterprisedb.com/docs",
algoliaIndex: algoliaIndex,
isDevelopment: !isBuild,
cacheBuster: 2, // for busting gh actions cache if needed
},
plugins: [
"gatsby-plugin-sass",
"gatsby-plugin-react-helmet",
"gatsby-transformer-sharp",
{
resolve: "gatsby-plugin-catch-links",
// plugin tests this against URL.pathname; it should roughly match tests in link.js
options: { excludePattern: /\.(?!mdx?)[\w]+$/ },
},
"gatsby-plugin-sharp",
{
resolve: "gatsby-plugin-netlify",
options: {
mergeLinkHeaders: false,
mergeCachingHeaders: false,
allPageHeaders: isProduction ? [] : ["X-Robots-Tag: noindex"],
headers: {
"/docs/pdfs/*": [
"X-Robots-Tag: noindex",
"X-Printshop-Directive: spiralbound",
],
},
},
},
{
resolve: "gatsby-plugin-sitemap",
options: {
query: `
{
site {
siteMetadata {
siteUrl
}
}
allMdx {
nodes {
fields {
path
mtime
}
}
}
allSitePage {
nodes {
path
}
}
}`,
resolvePages: ({
allSitePage: { nodes: allPages },
allMdx: { nodes: allMdxNodes },
}) => {
const knownPaths = new Set(allPages.map((p) => p.path));
const mapPathToTime = allMdxNodes.reduce((acc, node) => {
if (knownPaths.has(node.fields.path))
acc[node.fields.path] = { lastmod: node.fields.mtime };
else
acc[replacePathVersion(node.fields.path)] = {
lastmod: node.fields.mtime,
};
return acc;
}, {});
return allPages.map((page) => {
return { ...page, ...mapPathToTime[page.path] };
});
},
serialize: ({ path, lastmod }) => {
return {
url: path,
lastmod,
};
},
}, // should produce 5968 <loc>s
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: "EDB Documentation",
short_name: "EDB Docs",
start_url: "/",
background_color: "#EBEFF2",
theme_color: "#EBEFF2",
// Enables "Add to Homescreen" prompt and disables browser UI (including back button)
// see https://developers.google.com/web/fundamentals/web-app-manifest/#display
display: "standalone",
icon: "static/images/favicon.png", // This path is relative to the root of the site.
// An optional attribute which provides support for CORS check.
// If you do not provide a crossOrigin option, it will skip CORS for manifest.
// Any invalid keyword or empty string defaults to `anonymous`
crossOrigin: `use-credentials`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "advocacy_docs",
path: "advocacy_docs",
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "images",
path: "static/images",
},
},
...externalSourcePlugins(),
{
resolve: "gatsby-plugin-mdx",
options: {
defaultLayouts: {
default: require.resolve("./src/components/layout.js"),
},
lessBabel: true,
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-images",
options: {
linkImagesToOriginal: false,
showCaptions: false,
maxWidth: 1080,
},
},
{
resolve: `gatsby-remark-autolink-headers`,
options: {
isIconAfterHeader: true,
className: "ml-1",
},
},
{
resolve: "gatsby-remark-prismjs",
options: {
noInlineHighlight: true,
aliases: {
postgresql: "sql",
sh: "shell",
"c++": "cpp",
console: "shell-session",
},
},
},
],
remarkPlugins: [
[require("./src/plugins/code-in-tables")],
[
require("remark-admonitions"),
{
tag: "!!!",
icons: "none",
infima: true,
customTypes: {
seealso: "note",
hint: "tip",
interactive: "interactive",
},
},
],
],
},
},
{
resolve: "gatsby-plugin-react-svg",
options: {
rule: {
include: /static/,
},
},
},
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [
`source code pro\:400`, // you can also specify font weights and styles
],
},
},
{
resolve: "gatsby-plugin-google-tagmanager",
options: {
id: process.env.GTM_ID,
},
},
process.env.FATHOM_SITE_ID && {
resolve: "@raae/gatsby-plugin-fathom",
options: {
site: process.env.FATHOM_SITE_ID,
// disable canonical coalescing for two reasons:
// #1, we actually want data on specific version requests (e.g. /epas/13/installing vs /epas/latest/installing),
// #2, it doesn't work properly: when navigating internally, it reports the canonical URL of the page we're coming *from*, not *to*!
canonical: false,
includedDomains: "www.enterprisedb.com", // don't report staging / draft / local builds
},
},
{
// This plugin must be placed last in your list of plugins to ensure that it can query all the GraphQL data
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
indexName: algoliaIndex,
queries: [
{
query: indexQuery,
transformer: algoliaTransformer,
indexName: algoliaIndex,
},
],
mergeSettings: true,
settings: {
advancedSyntax: true,
distinct: true,
attributeForDistinct: "pagePath",
attributesToSnippet: ["excerpt"],
attributesForFaceting: ["product", "type", "version", "isLatest"],
customRanking: ["desc(isLatest)", "asc(navDepth)"],
searchableAttributes: ["title", "excerpt", "path"],
},
chunkSize: 1000,
enablePartialUpdates: false,
skipIndexing: process.env.INDEX_ON_BUILD !== "true",
},
},
].filter((p) => !!p),
};