forked from EnterpriseDB/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
343 lines (328 loc) · 9.14 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
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
});
const gracefulFs = require("graceful-fs");
const algoliaTransformer = require("./src/constants/algolia-indexing.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 = {
ark: { name: "ark", path: "product_docs/docs/ark" },
bart: { name: "bart", path: "product_docs/docs/bart" },
bdr: { name: "bdr", path: "product_docs/docs/bdr" },
biganimal: { name: "biganimal", path: "product_docs/docs/biganimal" },
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" },
eprs: { name: "eprs", path: "product_docs/docs/eprs" },
hadoop_data_adapter: {
name: "hadoop_data_adapter",
path: "product_docs/docs/hadoop_data_adapter",
},
harp: { name: "harp", path: "product_docs/docs/harp" },
jdbc_connector: {
name: "jdbc_connector",
path: "product_docs/docs/jdbc_connector",
},
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" },
pglogical: { name: "pglogical", path: "product_docs/docs/pglogical" },
pgpool: { name: "pgpool", path: "product_docs/docs/pgpool" },
postgis: { name: "postgis", path: "product_docs/docs/postgis" },
repmgr: { name: "repmgr", path: "product_docs/docs/repmgr" },
slony: { name: "slony", path: "product_docs/docs/slony" },
};
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",
"gatsby-transformer-json",
"gatsby-plugin-catch-links",
"gatsby-plugin-sharp",
{
resolve: "gatsby-plugin-netlify",
options: {
headers: {
"/*": isProduction ? [] : ["X-Robots-Tag: noindex"],
"/static/*.pdf": ["X-Robots-Tag: noindex"],
},
},
},
{
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 mapPathToTime = allMdxNodes.reduce((acc, node) => {
acc[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,
},
},
{
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",
},
},
},
],
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,
},
},
{
// 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,
},
],
chunkSize: 1000,
enablePartialUpdates: false,
skipIndexing: process.env.INDEX_ON_BUILD !== "true",
},
},
],
};