forked from apollographql/gatsby-theme-apollo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-config.js
199 lines (195 loc) · 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
const path = require('path');
const remarkTypescript = require('remark-typescript');
const {colors} = require('gatsby-theme-guide-core/src/utils/colors');
const {HEADER_HEIGHT} = require('./src/utils');
module.exports = ({
root,
siteName,
pageTitle,
description,
githubHost = 'github.com',
githubRepo,
baseDir = '',
contentDir = 'content',
versions = {},
gaTrackingId,
ignore,
checkLinksOptions,
gatsbyRemarkPlugins = [],
remarkPlugins = [],
baseUrl
}) => {
const allGatsbyRemarkPlugins = [
{
// doesn't work when placed last in plugin order
resolve: require.resolve('./plugins/gatsby-remark-rewrite-urls'),
},
{
resolve: 'gatsby-remark-autolink-headers',
options: {
offsetY: HEADER_HEIGHT
}
},
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
ignoreFileExtensions: []
}
},
{
resolve: 'gatsby-remark-mermaid',
options: {
mermaidOptions: {
themeCSS: `
.node rect,
.node circle,
.node polygon,
.node path {
stroke-width: 2px;
stroke: ${colors.primary};
fill: ${colors.background};
}
.node.secondary rect,
.node.secondary circle,
.node.secondary polygon,
.node.tertiary rect,
.node.tertiary circle,
.node.tertiary polygon {
fill: white;
}
.node.secondary rect,
.node.secondary circle,
.node.secondary polygon {
stroke: ${colors.secondary};
}
.cluster rect,
.node.tertiary rect,
.node.tertiary circle,
.node.tertiary polygon {
stroke: ${colors.tertiaryLight};
}
.cluster rect {
fill: none;
stroke-width: 2px;
}
.label, .edgeLabel {
background-color: white;
line-height: 1.3;
}
.edgeLabel rect {
background: none;
fill: none;
}
.messageText, .noteText, .loopText {
font-size: 12px;
stroke: none;
}
g rect, polygon.labelBox {
stroke-width: 2px;
}
g rect.actor {
stroke: ${colors.tertiary};
fill: white;
}
g rect.note {
stroke: ${colors.secondary};
fill: white;
}
g line.loopLine, polygon.labelBox {
stroke: ${colors.primary};
fill: white;
}
`
}
}
},
'gatsby-remark-code-titles',
{
resolve: 'gatsby-remark-prismjs',
// https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-prismjs#how-to-use
options: {
showLineNumbers: true,
aliases: {
sh: "bash",
gql: "graphql"
}
}
},
'gatsby-remark-rewrite-relative-links',
// {
// resolve: 'gatsby-remark-check-links',
// options: checkLinksOptions
// },
...gatsbyRemarkPlugins
];
const plugins = [
'gatsby-theme-guide-core',
'gatsby-theme-material-ui',
{
resolve: 'gatsby-source-filesystem',
options: {
path: path.join(root, contentDir),
name: 'docs',
ignore
}
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: allGatsbyRemarkPlugins
}
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: allGatsbyRemarkPlugins,
remarkPlugins: [
[remarkTypescript, {wrapperComponent: 'MultiCodeBlock'}],
...remarkPlugins
],
extensions: [`.mdx`, `.md`]
}
},
...Object.entries(versions).map(([name, branch]) => ({
resolve: 'gatsby-source-git',
options: {
name,
branch,
remote: `https://${githubHost}/${githubRepo}`,
patterns: [
path.join(baseDir, contentDir, '**'),
path.join(baseDir, 'gatsby-config.js'),
path.join(baseDir, '_config.yml')
]
}
})),
// https://www.gatsbyjs.com/docs/adding-search-with-algolia/
// Seems like docsearch is easier, even when running it yourself:
// https://docsearch.algolia.com/docs/run-your-own
// {
// resolve: `gatsby-plugin-algolia`,
// options: {
// appId: process.env.GATSBY_ALGOLIA_APP_ID,
// apiKey: process.env.ALGOLIA_ADMIN_KEY,
// queries: require("./src/utils/algolia-queries")
// },
// }
];
if (gaTrackingId) {
plugins.push({
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingIds: Array.isArray(gaTrackingId) ? gaTrackingId : [gaTrackingId]
}
});
}
return {
siteMetadata: {
title: pageTitle || siteName,
siteName,
description,
siteUrl: baseUrl
},
plugins
};
};