forked from MetaMask/metamask-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docusaurus.config.js
587 lines (570 loc) · 19.5 KB
/
docusaurus.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const codeTheme = require("prism-react-renderer/themes/dracula");
const remarkCodesandbox = require("remark-codesandbox");
const isProd = process.env.NODE_ENV === "production";
/** @type {import('@docusaurus/types').Config} */
const config = {
title: "MetaMask developer documentation",
// tagline: '',
url: "https://docs.metamask.io",
baseUrl: process.env.DEST || "/", // overwritten in github action for staging / latest
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
favicon: "img/metamask-fox.svg",
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: "metamask", // Usually your GitHub org/user name.
projectName: "metamask-docs", // Usually your repo name.
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: "en",
locales: ["en"/*, "ru", "zh"*/],
},
trailingSlash: true,
scripts: [
{ src: "https://cmp.osano.com/AzZMxHTbQDOQD8c1J/a2e89f0e-f467-4542-bfea-30ea2c1a6648/osano.js" },
{ src: "https://plausible.io/js/script.js", defer: true, "data-domain": "docs.metamask.io" },
{ src: "/js/feedback-script.js", defer: true, async: true },
{ src: "/js/getfeedback.js", defer: true, async: true },
],
markdown: {
mermaid: true,
},
themes: ["@docusaurus/theme-mermaid"],
presets: [
[
"@metamask/docusaurus-openrpc/dist/preset",
/** @type {import('@metamask/docusaurus-openrpc/dist/preset').Options} */
({
docs: {
path: "wallet",
routeBasePath: "wallet",
sidebarPath: require.resolve("./wallet-sidebar.js"),
breadcrumbs: false,
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
remarkPlugins: [
require("remark-docusaurus-tabs"),
[remarkCodesandbox, {
mode: "iframe",
autoDeploy: process.env.NODE_ENV === "production",
}],
],
openrpc: {
openrpcDocument: "https://metamask.github.io/api-specs/latest/openrpc.json",
path: "reference",
sidebarLabel: "JSON-RPC API",
},
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
}),
],
],
plugins: [
[
"@docusaurus/plugin-content-docs",
({
id: "snaps",
path: "snaps",
routeBasePath: "snaps",
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
sidebarPath: require.resolve("./snaps-sidebar.js"),
breadcrumbs: false,
remarkPlugins: [
require("remark-docusaurus-tabs"),
],
admonitions: {
tag: ":::",
keywords: [
"info",
"success",
"danger",
"note",
"tip",
"warning",
"important",
"caution",
"security",
"flaskOnly",
],
},
}),
],
[
"@docusaurus/plugin-content-docs",
{
id: "services",
path: "services",
routeBasePath: "services",
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
sidebarPath: require.resolve("./services-sidebar.js"),
breadcrumbs: false,
},
],
[
"@docusaurus/plugin-content-docs",
{
id: "docs",
path: "docs",
routeBasePath: "/",
editUrl: "https://github.com/MetaMask/metamask-docs/edit/main/",
sidebarPath: false,
breadcrumbs: false,
},
],
[
"@docusaurus/plugin-client-redirects",
{
fromExtensions: ["html", "htm"],
// These redirects are (mostly) organized in the same order as the sidebar.
redirects: [
{
from: ["/guide", "/guide/common-terms", "/guide/contributors", "/wallet/how-to/get-started-building", "/wallet/how-to/set-up-dev-environment", "/guide/create-dapp", "/guide/getting-started", "/wallet/category/get-started", "/wallet/get-started/set-up-dev-environment", "/wallet/how-to/get-started-building/set-up-dev-environment"],
to: "/wallet",
},
{
from: "/wallet/category/how-to",
to: "/wallet/how-to",
},
{
from: ["/wallet/quickstart/javascript", "/wallet/quickstart/react", "/wallet/quickstart/other-platforms", "/wallet/how-to/discover-multiple-wallets", "/wallet/how-to/detect-wallet", "/wallet/how-to/detect-wallet/multiple-wallets", "/guide/metamask-extension-provider", "/wallet/how-to/access-provider"],
to: "/wallet/how-to/connect",
},
{
from: ["/wallet/get-started/detect-metamask", "/wallet/how-to/detect-metamask", "/wallet/how-to/detect-wallet/metamask"],
to: "/wallet/how-to/connect/detect-metamask",
},
{
from: ["/guide/accessing-accounts", "/wallet/how-to/access-accounts", "/wallet/get-started/access-accounts"],
to: "/wallet/how-to/connect/access-accounts",
},
{
from: ["/wallet/get-started/detect-network", "/wallet/how-to/connect/detect-network", "/wallet/how-to/detect-network"],
to: "/wallet/how-to/manage-networks/detect-network",
},
{
from: "/wallet/how-to/add-network",
to: "/wallet/how-to/manage-networks/add-network",
},
{
from: "/guide/sending-transactions",
to: "/wallet/how-to/send-transactions",
},
{
from: "/guide/signing-data",
to: "/wallet/how-to/sign-data",
},
{
from: "/wallet/how-to/use-siwe",
to: "/wallet/how-to/sign-data/siwe",
},
{
from: ["/guide/registering-your-token", "/wallet/how-to/register-token"],
to: "/wallet/how-to/display/tokens",
},
{
from: ["/guide/registering-function-names", "/wallet/how-to/register-method-names"],
to: "/wallet/how-to/display/method-names",
},
{
from: ["/guide/defining-your-icon", "/wallet/how-to/set-icon"],
to: "/wallet/how-to/display/icon",
},
{
from: "/wallet/how-to/request-permissions",
to: "/wallet/how-to/manage-permissions",
},
{
from: ["/guide/mobile-getting-started", "/guide/site-compatibility-checklist", "/guide/mobile-best-practices", "/wallet/how-to/use-mobile", "/wallet/how-to/integrate-with-mobile", "/sdk"],
to: "/wallet/how-to/use-sdk",
},
{
from: "/wallet/how-to/sign-data/connect-and-sign",
to: "/wallet/how-to/use-sdk/javascript/connect-and-sign",
},
{
from: ["/wallet/how-to/use-3rd-party-integrations/js-infura-api", "/wallet/how-to/make-read-only-requests"],
to: "/wallet/how-to/use-sdk/javascript/make-read-only-requests",
},
{
from: "/wallet/how-to/batch-json-rpc-requests",
to: "/wallet/how-to/use-sdk/javascript/batch-json-rpc-requests",
},
{
from: "/wallet/how-to/display/custom-modals",
to: "/wallet/how-to/use-sdk/javascript/display-custom-modals",
},
{
from: "/wallet/how-to/use-3rd-party-integrations/unity-dweb",
to: "/wallet/how-to/use-sdk/gaming/unity/dweb",
},
{
from: "/wallet/how-to/use-3rd-party-integrations/unity-infura",
to: "/wallet/how-to/use-sdk/gaming/unity/infura",
},
{
from: "/wallet/how-to/use-3rd-party-integrations",
to: "/wallet/how-to/use-sdk/3rd-party-libraries",
},
{
from: "/wallet/how-to/use-3rd-party-integrations/web3-onboard",
to: "/wallet/how-to/use-sdk/3rd-party-libraries/web3-onboard",
},
{
from: ["/guide/initializing-dapps", "/wallet/how-to/interact-with-smart-contracts"],
to: "/wallet/concepts/smart-contracts",
},
{
from: "/guide/ethereum-provider",
to: "/wallet/reference/provider-api",
},
{
from: ["/guide/onboarding-library", "/wallet/how-to/use-onboarding-library"],
to: "/wallet/how-to/onboard-users",
},
{
from: ["/wallet/get-started/run-development-network", "/wallet/how-to/get-started-building/run-devnet"],
to: "/wallet/how-to/run-devnet",
},
{
from: "/wallet/how-to/get-started-building/secure-dapp",
to: "/wallet/how-to/secure-dapp",
},
{
from: "/wallet/category/concepts",
to: "/wallet/concepts",
},
{
from: ["/guide/provider-migration", "/wallet/concepts/provider-api", "/wallet/concepts/rpc-api", "/wallet/how-to/migrate-api", "/wallet/concepts/apis"],
to: "/wallet/concepts/wallet-api",
},
{
from: "/wallet/category/tutorials",
to: "/wallet/tutorials",
},
{
from: "/wallet/tutorials/simple-react-dapp",
to: "/wallet/tutorials/react-dapp-local-state",
},
{
from: "/wallet/category/reference",
to: "/wallet/reference",
},
{
from: ["/guide/rpc-api", "/wallet/reference/rpc-api"],
to: "/wallet/reference/json-rpc-api",
},
{
from: "/guide/snaps",
to: "/snaps",
},
{
from: "/snaps/category/get-started",
to: "/snaps/get-started",
},
{
from: "/snaps/get-started/install-snaps",
to: "/snaps/get-started/install-flask",
},
{
from: ["/guide/snaps-concepts", "/snaps/category/concepts", "/snaps/concepts/lifecycle", "/snaps/concepts/user-interface", "/snaps/concepts/overview", "/snaps/concepts", "/snaps/concepts/apis", "/snaps/concepts/execution-environment"],
to: "/snaps/learn/about-snaps",
},
{
from: ["/snaps/concepts/anatomy", "/snaps/concepts/files"],
to: "/snaps/learn/about-snaps/files",
},
{
from: ["/snaps/category/tutorials", "/snaps/tutorials"],
to: "/snaps/learn/tutorials",
},
{
from: "/snaps/tutorials/gas-estimation",
to: "/snaps/learn/tutorials/gas-estimation",
},
{
from: "/snaps/tutorials/transaction-insights",
to: "/snaps/learn/tutorials/transaction-insights",
},
{
from: "/snaps/category/how-to",
to: "/snaps/how-to",
},
{
from: "/snaps/how-to/use-custom-ui",
to: "/snaps/features/custom-ui",
},
{
from: "/snaps/how-to/localize-a-snap",
to: "/snaps/features/localization",
},
{
from: "/snaps/how-to/manage-keys",
to: "/snaps/features/non-evm-networks",
},
{
from: "/snaps/concepts/keyring-api",
to: "/snaps/features/custom-evm-accounts",
},
{
from: "/snaps/tutorials/custom-evm-accounts",
to: "/snaps/features/custom-evm-accounts/create-account-snap",
},
{
from: ["/snaps/concepts/design-guidelines", "/snaps/how-to/design-a-snap"],
to: "/snaps/learn/best-practices/design-guidelines",
},
{
from: ["/snaps/concepts/security-guidelines", "/snaps/how-to/secure-a-snap"],
to: "/snaps/learn/best-practices/security-guidelines",
},
{
from: "/guide/snaps-permissions",
to: "/snaps/how-to/request-permissions",
},
{
from: ["/guide/snaps-patching-dependencies", "/snaps/how-to/troubleshoot"],
to: "/snaps/how-to/debug-a-snap/common-issues",
},
{
from: ["/guide/snaps-development-guide", "/snaps/how-to/develop-a-snap"],
to: "/snaps/how-to/publish-a-snap",
},
{
from: ["/snaps/how-to/work-with-existing-snaps", "/snaps/how-to/use-3rd-party-snaps"],
to: "/snaps/how-to/connect-to-a-snap",
},
{
from: "/snaps/category/reference",
to: "/snaps/reference",
},
{
from: ["/guide/snaps-rpc-api", "/snaps/reference/rpc-api"],
to: "/snaps/reference/snaps-api",
},
{
from: ["/guide/snaps-exports", "/snaps/reference/exports"],
to: "/snaps/reference/entry-points",
},
].reduce((acc, item) => {
acc.push(item);
acc.push({ from: item.from + ".html", to: item.to });
return acc;
}, []),
createRedirects(existingPath) {
if (existingPath.includes("/use-sdk")) {
// Redirect from /connect/set-up-sdk/X to /use-sdk/X
return [
existingPath.replace("/use-sdk", "/connect/set-up-sdk"),
];
}
if (existingPath.includes("/use-sdk/gaming/unity")) {
return [
existingPath.replace("/use-sdk/gaming/unity", "/interact-with-smart-contracts/unity"),
];
}
if (existingPath.includes("/features/custom-evm-accounts")) {
return [
existingPath.replace("/features/custom-evm-accounts", "/how-to/use-keyring-api"),
];
}
return undefined;
},
},
],
isProd ?
[
"docusaurus-plugin-segment",
{
apiKey: process.env.SEGMENT_ANALYTICS_KEY,
load: { cookie: { sameSite: "None", secure: true } },
page: true,
},
] : null,
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
metadata: [
{ name: "og:image", content: "/img/metamaskog.jpeg" },
],
navbar: {
title: " │ Documentation",
logo: {
alt: "MetaMask logo",
src: "img/metamask-logo.svg",
srcDark: "img/metamask-logo-dark.svg",
width: 150,
},
items: [
{
to: "wallet",
label: "Wallet",
},
{
to: "snaps",
label: "Snaps",
},
{
to: "services",
label: "Services",
},
{
to: "whats-new",
label: "What's new?",
position: "right",
},
/* Language drop down
{
type: "localeDropdown",
position: "right",
},
*/
],
},
docs: {
sidebar: {
autoCollapseCategories: false,
},
},
footer: {
logo: {
alt: "MetaMask logo",
src: "img/metamask-logo.svg",
srcDark: "img/metamask-logo-dark.svg",
href: "https://metamask.io/",
width: 250,
},
links: [
{
title: "Documentation",
items: [
{
label: "Home",
to: "/",
},
{
label: "MetaMask wallet",
to: "/wallet",
},
{
label: "MetaMask SDK",
to: "/wallet/how-to/use-sdk",
},
{
label: "Snaps",
to: "/snaps",
},
{
label: "Services",
to: "/services",
},
],
},
{
title: "GitHub",
items: [
{
label: "Documentation GitHub",
href: "https://github.com/MetaMask/metamask-docs",
},
{
label: "MetaMask wallet GitHub",
href: "https://github.com/MetaMask/metamask-extension/",
},
{
label: "MetaMask SDK GitHub",
href: "https://github.com/MetaMask/metamask-sdk/",
},
{
label: "Snaps GitHub",
href: "https://github.com/MetaMask/snaps-monorepo",
},
],
},
{
title: "Community",
items: [
{
label: "Consensys Discord",
href: "https://discord.gg/consensys",
},
{
label: "Contribute to MetaMask",
href: "https://github.com/MetaMask/metamask-extension/blob/develop/docs/README.md",
},
{
label: "Contribute to the docs",
href: "https://github.com/MetaMask/metamask-docs/blob/main/CONTRIBUTING.md",
},
],
},
{
title: "Legal",
items: [
{
label: "Privacy Policy",
href: "https://consensys.net/privacy-policy/",
},
{
label: "Terms of Use",
href: "https://consensys.net/terms-of-use/",
},
{
label: "Contributor License Agreement",
href: "https://metamask.io/cla/",
},
{
html: "<button id='manage-cookie-btn'>Manage cookies</button>",
},
],
},
],
copyright: `© ${new Date().getFullYear()} MetaMask • A Consensys Formation`,
},
prism: {
theme: codeTheme,
additionalLanguages: ["csharp","swift","gradle","kotlin"],
},
algolia: {
// The application ID provided by Algolia
appId: "AWX4QVM59R",
// Public API key: it is safe to commit it
apiKey: "6095a25a6824bfa909fa0692e6847ec4",
indexName: "mm--v2-staging",
// Optional: see doc section below
contextualSearch: true,
// Optional: Specify domains where the navigation should occur through window.location instead on history.push. Useful when our Algolia config crawls multiple documentation sites and we want to navigate with window.location.href to them.
// externalUrlRegex: "external\\.com|domain\\.com",
// Optional: Replace parts of the item URLs from Algolia. Useful when using the same search index for multiple deployments using a different baseUrl. You can use regexp or string in the `from` param. For example: localhost:3000 vs myCompany.com/docs
replaceSearchResultPathname: {
from: "/",
to: process.env.DEST || "/",
},
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: "search",
//... other Algolia params
},
mermaid: {
options: {
fontFamily: "arial, verdana, sans-serif;",
wrap: true,
sequence: {
diagramMarginX: 25,
diagramMarginY: 25,
},
flowchart: {
diagramPadding: 5,
nodeSpacing: 75,
},
},
},
}),
};
module.exports = config;