forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-config.js
More file actions
297 lines (292 loc) · 8.09 KB
/
gatsby-config.js
File metadata and controls
297 lines (292 loc) · 8.09 KB
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
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`;
module.exports = {
flags: {
DEV_SSR: true,
LAZY_IMAGES: true,
QUERY_ON_DEMAND: 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',
},
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-layout',
options: {
component: require.resolve('./src/layouts'),
},
},
{
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-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,
},
},
],
},
},
{
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: {
maxHeight: 400,
maxWidth: 1200,
linkImagesToOriginal: false,
},
},
{
resolve: `gatsby-remark-autolink-headers`,
options: {
enableCustomId: true,
icon: false,
},
},
],
},
},
`gatsby-transformer-yaml`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `./src/nav/`,
},
},
{
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,
},
},
{
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',
],
};