forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
354 lines (348 loc) · 10.5 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
const fs = require('fs');
const path = require('path');
const indentedCodeBlock = require('./codemods/indentedCodeBlock');
const siteUrl = 'https://docs.newrelic.com';
const dataDictionaryPath = `${__dirname}/src/data-dictionary`;
const autoLinkHeaders = {
resolve: 'gatsby-remark-autolink-headers',
options: {
icon:
'<svg xmlns="http://www.w3.org/2000/svg" focusable="false" width="1rem" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg>',
},
};
module.exports = {
flags: {
DEV_SSR: true,
LAZY_IMAGES: true,
QUERY_ON_DEMAND: true,
PRESERVE_WEBPACK_CACHE: true,
},
siteMetadata: {
title: 'New Relic Documentation',
titleTemplate: '%s | New Relic Documentation',
description: 'New Relic Documentation',
author: 'New Relic',
repository: 'https://github.com/newrelic/docs-website',
siteUrl,
branch: 'develop',
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: '@newrelic/gatsby-theme-newrelic',
options: {
layout: {
contentPadding: '2rem',
maxWidth: '1600px',
component: require.resolve('./src/layouts'),
},
i18n: {
translationsPath: `${__dirname}/src/i18n/translations`,
additionalLocales: [{ name: '日本語', locale: 'jp' }],
},
prism: {
languages: [
'xml',
'xml-doc',
'c',
'go',
'java',
'php',
'phpdoc',
'csharp',
'python',
],
},
// This option is set to disallow to prevent crawling of the site during preview
// mode
robots: {
host: 'https://docs-preview.newrelic.com',
sitemap: 'https://docs-preview.newrelic.com/sitemap.xml',
policy: [{ userAgent: '*', disallow: '/' }],
},
newrelic: {
configs: {
development: {
instrumentationType: 'proAndSPA',
accountId: '10175106',
trustKey: '1',
agentID: '23865145',
licenseKey: '528f970912',
applicationID: '23865145',
beacon: 'staging-bam.nr-data.net',
errorBeacon: 'staging-bam.nr-data.net',
},
},
},
},
},
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'New Relic Documentation',
short_name: 'New Relic Documentation',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/favicon.png', // This path is relative to the root of the site.
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'markdown-pages',
path: `${__dirname}/src/content`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'data-dictionary',
path: dataDictionaryPath,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'translated-content',
path: `${__dirname}/src/i18n/content`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'translated-nav',
path: `${__dirname}/src/i18n/nav`,
},
},
{
resolve: 'gatsby-transformer-json',
options: {
// If we need to source json files other than the i18n/nav, we should
// consider making this dynamic. See the docs for ways to do this.
//
// https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-json
typeName: 'TranslatedNavJson',
},
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 850,
linkImagesToOriginal: false,
},
},
// Gifs are not supported via gatsby-remark-images (https://github.com/gatsbyjs/gatsby/issues/7317).
// It is recommended to therefore use this plugin to copy files with a
// .gif extension to the public folder.
//
// Source: https://github.com/gatsbyjs/gatsby/issues/7317#issuecomment-412984851
'gatsby-remark-copy-linked-files',
'gatsby-remark-videos',
{
resolve: 'gatsby-remark-gifs',
options: {
maxWidth: 850,
},
},
autoLinkHeaders,
// This MUST come after `gatsby-remark-autolink-headers` to ensure the
// link created for the icon has the proper id
'gatsby-remark-custom-heading-ids',
],
},
},
{
resolve: 'gatsby-plugin-mdx',
options: {
// Include our patch for handling indented code blocks to ensure the
// fence does not get rendered as part of the block. There is an open
// issue in the MDX project about this:
// https://github.com/mdx-js/mdx/issues/1283
//
// If this is addressed in MDX v2, we can safely remove this.
remarkPlugins: [indentedCodeBlock],
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 1200,
linkImagesToOriginal: false,
},
},
autoLinkHeaders,
// This MUST come after `gatsby-remark-autolink-headers` to ensure the
// link created for the icon has the proper id.
//
// This also uses the `require.resolve` syntax because
// `gatsby-plugin-mdx` is unable to resolve local plugins.
// https://github.com/gatsbyjs/gatsby/issues/23194
{
resolve: require.resolve(
'./plugins/gatsby-remark-custom-heading-ids'
),
},
{
resolve: require.resolve('./plugins/gatsby-remark-mdx-v2-images'),
},
// Gifs are not supported via gatsby-remark-images (https://github.com/gatsbyjs/gatsby/issues/7317).
// It is recommended to therefore use this plugin to copy files with a
// .gif extension to the public folder.
//
// Source: https://github.com/gatsbyjs/gatsby/issues/7317#issuecomment-412984851
'gatsby-remark-copy-linked-files',
{
resolve: require.resolve('./plugins/gatsby-remark-gifs'),
options: {
maxWidth: 1200,
},
},
],
},
},
`gatsby-transformer-yaml`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `./src/nav/`,
},
},
'gatsby-plugin-generate-doc-json',
{
resolve: 'gatsby-plugin-generate-json',
options: {
query: `
{
allMarkdownRemark(filter: {fields: {slug: {regex: "/whats-new/"}}}) {
nodes {
frontmatter {
title
releaseDate
getStartedLink
learnMoreLink
summary
}
fields {
slug
}
html
}
}
}
`,
path: '/api/nr1/content/nr1-announcements.json',
serialize: ({ data }) => {
const ids = JSON.parse(
fs.readFileSync(path.join(__dirname, 'src/data/whats-new-ids.json'))
);
return {
announcements: data.allMarkdownRemark.nodes.map(
({ frontmatter, html, fields }) => ({
docsID: ids[fields.slug],
title: frontmatter.title,
summary: frontmatter.summary,
releaseDateTime: frontmatter.releaseDate,
learnMoreLink: frontmatter.learnMoreLink,
getStartedLink: frontmatter.getStartedLink,
body: html,
docUrl: new URL(fields.slug, siteUrl).href,
})
),
};
},
},
},
{
resolve: 'gatsby-plugin-generate-json',
options: {
path: '/api/nr1/content/nr1-announcements/ids.json',
serialize: () => {
const ids = JSON.parse(
fs.readFileSync(path.join(__dirname, 'src/data/whats-new-ids.json'))
);
return {
announcements: Object.values(ids).map((id) => ({
docsID: id,
})),
};
},
},
},
{
resolve: `gatsby-plugin-json-output`,
options: {
siteUrl,
graphQLQuery: `
{
allDataDictionaryEvent {
edges {
node {
name
definition {
rawMarkdownBody
}
dataSources
childrenDataDictionaryAttribute {
name
definition {
rawMarkdownBody
}
units
}
}
}
}
}
`,
serializeFeed: ({ data }) =>
data.allDataDictionaryEvent.edges.map(({ node }) => ({
name: node.name,
definition:
node.definition && node.definition.rawMarkdownBody.trim(),
dataSources: node.dataSources,
attributes: node.childrenDataDictionaryAttribute.map(
(attribute) => ({
name: attribute.name,
definition: attribute.definition.rawMarkdownBody.trim(),
units: attribute.units,
})
),
})),
feedFilename: 'data-dictionary',
nodesPerFeedFile: Infinity,
},
},
'gatsby-plugin-release-note-rss',
{
resolve: 'gatsby-source-data-dictionary',
options: {
path: dataDictionaryPath,
},
},
'gatsby-source-nav',
{
resolve: 'gatsby-plugin-auto-index-pages',
options: {
skippedDirectories: ['', 'whats-new', 'docs/release-notes'],
},
},
'gatsby-plugin-meta-redirect',
],
};