Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
366 lines (359 loc) · 11.8 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
366 lines (359 loc) · 11.8 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
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
import fs from 'node:fs';
import path from 'node:path';
import { logger } from '@docusaurus/logger';
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import npm2yarn from '@docusaurus/remark-plugin-npm2yarn';
import * as dotenv from 'dotenv';
import { themes as prismThemes } from 'prism-react-renderer';
import remarkGithubAdmonitionsToDirectives, {
DEFAULT_MAPPING,
} from 'remark-github-admonitions-to-directives';
import apiLabels from './src/transformers/api-labels.ts';
import apiOptionsClass from './src/transformers/api-options-class.ts';
import apiStructurePreviews from './src/transformers/api-structure-previews.ts';
import jsCodeBlocks from './src/transformers/js-code-blocks.ts';
import fiddleEmbedder from './src/transformers/fiddle-embedder.ts';
import githubContentsLinks from './src/transformers/github-content-links.ts';
import apiHistory from './src/transformers/api-history.ts';
// Picks up a local GITHUB_TOKEN so API history tables resolve versions in local
// dev. Existing environment variables win, which keeps CI behavior unchanged.
dotenv.config();
let docsSHA = undefined;
try {
docsSHA = fs
.readFileSync(path.resolve(__dirname, './docs/latest/.sha'), 'utf-8')
.trim();
} catch {
logger.warn('No .sha file found in docs/latest directory');
}
const config: Config = {
title: 'Electron',
tagline: 'Build cross-platform desktop apps with JavaScript, HTML, and CSS',
url: 'https://electronjs.org',
baseUrl: '/',
onBrokenLinks: 'warn',
favicon: 'assets/img/favicon.ico',
organizationName: 'electron',
projectName: 'electron',
headTags: docsSHA
? [
{
tagName: 'meta',
attributes: {
name: 'docs-sha',
content: docsSHA,
},
},
]
: [],
markdown: {
mermaid: true,
},
themes: ['@docusaurus/theme-mermaid'],
i18n: {
defaultLocale: 'en',
locales: ['en', 'de', 'es', 'fr', 'ja', 'pt', 'ru', 'zh'],
path: 'i18n',
// Due to a refactor in Docusaurus 3.9, the inferred localeDropdown baseURL paths
// get messed up because we build the `en` locale separately from the translated ones.
// This part of the config defines those manually.
localeConfigs: {
de: {
baseUrl: '/de/',
},
es: {
baseUrl: '/es/',
},
fr: {
baseUrl: '/fr/',
},
ja: {
baseUrl: '/ja/',
},
pt: {
baseUrl: '/pt/',
},
ru: {
baseUrl: '/ru/',
},
zh: {
baseUrl: '/zh/',
},
},
},
themeConfig: {
colorMode: {
//Default to light or dark depending on system theme.
respectPrefersColorScheme: true,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
additionalLanguages: ['diff', 'json', 'json5'],
},
tableOfContents: {
minHeadingLevel: 2,
maxHeadingLevel: 4,
},
navbar: {
title: 'Electron',
style: 'dark',
logo: {
alt: 'Electron homepage',
src: 'assets/img/logo.svg',
},
items: [
{
label: 'Docs',
type: 'doc',
docId: 'latest/tutorial/introduction',
position: 'left',
},
{
label: 'API',
type: 'doc',
docId: 'latest/api/app',
position: 'left',
},
{ to: 'blog', label: 'Blog', position: 'left' },
{
type: 'dropdown',
label: 'Tools',
position: 'left',
items: [
{ to: 'https://electronforge.io', label: 'Electron Forge' },
{ to: 'fiddle', label: 'Electron Fiddle' },
],
},
{
type: 'dropdown',
label: 'Community',
position: 'left',
items: [
{ to: 'governance', label: 'Governance' },
{ to: 'apps', label: 'Showcase' },
{ to: 'community', label: 'Resources' },
],
},
{
href: 'https://releases.electronjs.org',
label: 'Releases',
position: 'right',
},
{
type: 'localeDropdown',
position: 'right',
},
{
href: 'https://github.com/electron/electron',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
},
footer: {
logo: {
alt: 'OpenJS Foundation Logo',
src: 'assets/img/openjsf_logo.svg',
srcDark: 'assets/img/openjsf_logo-dark.svg',
href: 'https://openjsf.org/',
},
links: [
{
title: 'Docs',
items: [
{
label: 'Getting Started',
to: '/docs/latest/',
},
{
label: 'API Reference',
to: '/docs/latest/api/app',
},
],
},
{
title: 'Checklists',
items: [
{
label: 'Performance',
to: '/docs/latest/tutorial/performance',
},
{
label: 'Security',
to: '/docs/latest/tutorial/security',
},
],
},
{
title: 'Tools',
items: [
{
label: 'Electron Forge',
to: 'https://electronforge.io',
},
{
label: 'Electron Fiddle',
to: '/fiddle',
},
],
},
{
title: 'Community',
items: [
{ label: 'Governance', to: '/governance' },
{ label: 'Resources', to: '/community' },
{
label: 'Bluesky',
href: 'https://bsky.app/profile/electronjs.org',
},
{
label: 'X',
href: 'https://x.com/electronjs',
},
{
html: '<a href="https://social.lfx.dev/@electronjs" target="_blank" rel="me" class="footer__link-item">Mastodon<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" style="margin-left: 0.3rem;"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a>',
},
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/electron',
},
],
},
{
title: 'More',
items: [
{
label: 'GitHub',
href: 'https://github.com/electron/electron',
},
{
label: 'Open Collective',
href: 'https://opencollective.com/electron',
},
{
label: 'Infrastructure Dashboard',
href: 'https://p.datadoghq.com/sb/c44e1df0-85d7-11ee-94c9-da7ad0900002-c245f7ef47d0d0c32abecdc0938c2a85',
},
],
},
],
copyright: `
<p>Copyright <a href="https://openjsf.org">OpenJS Foundation</a> and Electron contributors. All rights reserved.
The <a href="https://openjsf.org">OpenJS Foundation</a> has registered trademarks and uses trademarks.
For a list of trademarks of the <a href="https://openjsf.org">OpenJS Foundation</a>, please see our
<a href="https://trademark-policy.openjsf.org">Trademark Policy</a> and <a href="https://trademark-list.openjsf.org">Trademark List</a>.
Trademarks and logos not indicated on the <a href="https://trademark-list.openjsf.org">list of OpenJS Foundation trademarks</a>
are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with
or endorsement by them.</p>
<p><a href="https://openjsf.org">The OpenJS Foundation</a> | <a href="https://terms-of-use.openjsf.org">Terms of Use</a> |
<a href="https://privacy-policy.openjsf.org">Privacy Policy</a> | <a href="https://bylaws.openjsf.org">Bylaws</a> |
<a href="https://code-of-conduct.openjsf.org">Code of Conduct</a> | <a href="https://trademark-policy.openjsf.org">Trademark Policy</a>
| <a href="https://trademark-list.openjsf.org">Trademark List</a> | <a href="https://www.linuxfoundation.org/cookies">Cookie Policy</a></p>`,
},
algolia: {
appId: 'MG3SRMK3K0',
apiKey: 'fdc2cf6080e499639d7e6b0278851ed4',
indexName: 'electronjs',
contextualSearch: true,
},
} satisfies Preset.ThemeConfig,
plugins: [
'docusaurus-plugin-sass',
path.resolve(__dirname, './src/plugins/apps/index.ts'),
path.resolve(__dirname, './src/plugins/releases/index.ts'),
path.resolve(__dirname, './src/plugins/fiddle/index.ts'),
path.resolve(__dirname, './src/plugins/governance/index.ts'),
path.resolve(__dirname, './src/plugins/markdown-output/index.ts'),
path.resolve(__dirname, './src/plugins/og-image/index.ts'),
],
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
beforeDefaultRemarkPlugins: [
[
remarkGithubAdmonitionsToDirectives,
{
mapping: DEFAULT_MAPPING,
},
],
],
sidebarPath: require.resolve('./sidebars.js'),
// The default generator sorts `autogenerated` items by file path,
// which orders `certificate-principal.md` before `certificate.md`
// ('-' sorts before '.'). Sort by doc id instead so that a doc
// comes before the docs whose names extend it.
sidebarItemsGenerator: async ({
defaultSidebarItemsGenerator,
...args
}) => {
const items = await defaultSidebarItemsGenerator(args);
const sortKey = (item: (typeof items)[number]) => {
if (item.type === 'doc') return item.id;
return 'label' in item ? (item.label ?? '') : '';
};
return [...items].sort((a, b) =>
sortKey(a).localeCompare(sortKey(b), 'en'),
);
},
routeBasePath: '/docs/',
editUrl: ({ docPath }) => {
const fixedPath = docPath.replace('latest/', '');
return `https://github.com/electron/electron/edit/main/docs/${fixedPath}`;
},
remarkPlugins: [
apiLabels,
apiOptionsClass,
apiStructurePreviews,
jsCodeBlocks,
fiddleEmbedder,
githubContentsLinks,
apiHistory,
[npm2yarn, { sync: true, converters: ['yarn'] }],
],
},
blog: {
// See `node_modules/@docusaurus/plugin-content-blog/src/pluginOptionSchema.ts` for full undocumented options
path: 'blog',
beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives],
blogSidebarCount: 'ALL',
blogSidebarTitle: 'Latest posts',
blogTitle: `Electron's blog`,
blogDescription: `Keep up to date with what's going on with the Electron project`,
onInlineAuthors: 'ignore',
onUntruncatedBlogPosts: 'ignore',
},
theme: {
customCss: [require.resolve('./src/css/custom.scss')],
},
gtag: {
trackingID: 'UA-160365006-1',
anonymizeIP: true,
},
} satisfies Preset.Options,
],
],
future: {
faster: {
rspackBundler: true,
rspackPersistentCache: false,
swcHtmlMinimizer: true,
ssgWorkerThreads: true,
swcJsLoader: true,
swcJsMinimizer: true,
lightningCssMinimizer: true,
mdxCrossCompilerCache: true,
},
v4: {
removeLegacyPostBuildHeadAttribute: true,
// FIXME: enabling this change breaks compilation
useCssCascadeLayers: false,
},
},
};
export default config;