forked from MetaMask/metamask-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docusaurus.config.js
469 lines (453 loc) · 13.9 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
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const codeTheme = require("prism-react-renderer/themes/dracula");
const remarkCodesandbox = require("remark-codesandbox");
/** @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"],
},
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" },
],
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 playground",
},
},
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"),
],
}),
],
[
"@docusaurus/plugin-client-redirects",
{
fromExtensions: ["html", "htm"],
redirects: [
{
from: "/guide/",
to: "/wallet/",
},
{
from: "/guide/getting-started",
to: "/wallet/how-to/get-started-building/set-up-dev-environment",
},
{
from: "/guide/common-terms",
to: "/wallet/",
},
{
from: "/guide/initializing-dapps",
to: "/wallet/how-to/interact-with-smart-contracts",
},
{
from: "/guide/accessing-accounts",
to: "/wallet/how-to/connect/access-accounts",
},
{
from: "/guide/sending-transactions",
to: "/wallet/how-to/send-transactions",
},
{
from: "/guide/ethereum-provider",
to: "/wallet/reference/provider-api",
},
{
from: "/guide/provider-migration",
to: "/wallet/how-to/migrate-api",
},
{
from: "/guide/rpc-api",
to: "/wallet/reference/rpc-api",
},
{
from: "/guide/signing-data",
to: "/wallet/how-to/sign-data",
},
{
from: "/guide/registering-function-names",
to: "/wallet/how-to/display/method-names",
},
{
from: "/guide/registering-your-token",
to: "/wallet/how-to/display/tokens",
},
{
from: "/guide/defining-your-icon",
to: "/wallet/how-to/display/icon",
},
{
from: "/guide/onboarding-library",
to: "/wallet/how-to/onboard-users",
},
{
from: "/guide/metamask-extension-provider",
to: "/wallet/how-to/access-provider",
},
{
from: "/guide/mobile-getting-started",
to: "/wallet/how-to/integrate-with-mobile",
},
{
from: "/guide/site-compatibility-checklist",
to: "/wallet/how-to/integrate-with-mobile",
},
{
from: "/guide/mobile-best-practices",
to: "/wallet/how-to/integrate-with-mobile",
},
{
from: "/guide/snaps",
to: "/snaps/",
},
{
from: "/guide/snaps-development-guide",
to: "/snaps/how-to/develop-a-snap",
},
{
from: "/guide/snaps-concepts",
to: "/snaps/concepts",
},
{
from: "/guide/snaps-rpc-api",
to: "/snaps/reference/rpc-api",
},
{
from: "/guide/snaps-permissions",
to: "/snaps/how-to/request-permissions",
},
{
from: "/guide/snaps-exports",
to: "/snaps/reference/exports",
},
{
from: "/guide/snaps-patching-dependencies",
to: "/snaps/how-to/troubleshoot",
},
{
from: "/guide/create-dapp",
to: "/wallet/how-to/get-started-building/set-up-dev-environment",
},
{
from: "/guide/contributors",
to: "/wallet/",
},
{
from: "/wallet/tutorials/simple-react-dapp",
to: "/wallet/tutorials/react-dapp-local-state",
},
{
from: "/wallet/category/how-to",
to: "/wallet/how-to",
},
{
from: "/wallet/category/concepts",
to: "/wallet/concepts",
},
{
from: "/wallet/category/tutorials",
to: "/wallet/tutorials",
},
{
from: "/wallet/category/reference",
to: "/wallet/reference",
},
{
from: "/snaps/category/get-started",
to: "/snaps/get-started",
},
{
from: "/snaps/category/how-to",
to: "/snaps/how-to",
},
{
from: "/snaps/category/concepts",
to: "/snaps/concepts",
},
{
from: "/snaps/category/tutorials",
to: "/snaps/tutorials",
},
{
from: "/snaps/category/reference",
to: "/snaps/reference",
},
{
from: "/wallet/category/get-started",
to: "/wallet/how-to/get-started-building",
},
{
from: "/wallet/get-started/set-up-dev-environment",
to: "/wallet/how-to/get-started-building/set-up-dev-environment",
},
{
from: "/wallet/get-started/run-development-network",
to: "/wallet/how-to/get-started-building/run-devnet",
},
{
from: "/wallet/how-to/secure-dapp",
to: "/wallet/how-to/get-started-building/secure-dapp",
},
{
from: "/wallet/get-started/detect-metamask",
to: "/wallet/how-to/connect/detect-metamask",
},
{
from: "/wallet/get-started/detect-network",
to: "/wallet/how-to/connect/detect-network",
},
{
from: "/wallet/get-started/access-accounts",
to: "/wallet/how-to/connect/access-accounts",
},
{
from: "/wallet/how-to/use-siwe",
to: "/wallet/how-to/sign-data/siwe",
},
{
from: "/wallet/how-to/use-mobile",
to: "/wallet/how-to/integrate-with-mobile",
},
{
from: "/wallet/how-to/use-onboarding-library",
to: "/wallet/how-to/onboard-users",
},
{
from: "/wallet/how-to/register-token",
to: "/wallet/how-to/display/tokens",
},
{
from: "/wallet/how-to/register-method-names",
to: "/wallet/how-to/display/method-names",
},
{
from: "/wallet/how-to/set-icon",
to: "/wallet/how-to/display/icon",
},
].reduce((acc, item) => {
acc.push(item);
acc.push({ from: item.from + ".html", to: item.to });
return acc;
}, []),
createRedirects(existingPath) {
if (existingPath.includes("/connect/set-up-sdk")) {
return [
existingPath.replace("/connect/set-up-sdk", "/use-sdk"),
];
}
return undefined;
},
},
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
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",
},
],
},
docs: {
sidebar: {
autoCollapseCategories: true,
},
},
footer: {
logo: {
alt: "MetaMask logo",
src: "img/metamask-logo.svg",
srcDark: "img/metamask-logo-dark.svg",
href: "https://metamask.io/",
width: 250,
},
links: [
{
title: "Wallet",
items: [
{
label: "Introduction",
to: "/wallet",
},
{
label: "How to guides",
to: "/wallet/category/how-to",
},
{
label: "Concepts",
to: "/wallet/concepts",
},
{
label: "Tutorials",
to: "/wallet/tutorials",
},
{
label: "Reference",
to: "/wallet/reference",
},
],
},
{
title: "Snaps",
items: [
{
label: "Introduction",
to: "/snaps",
},
{
label: "Get started",
to: "/snaps/get-started",
},
{
label: "How to guides",
to: "/snaps/how-to",
},
{
label: "Tutorials",
to: "/snaps/tutorials",
},
{
label: "Reference",
to: "/snaps/reference",
},
],
},
{
title: "Community",
items: [
{
label: "Consensys Discord",
href: "https://discord.gg/consensys",
},
{
label: "Documentation GitHub",
href: "https://github.com/MetaMask/metamask-docs",
},
{
label: "MetaMask wallet GitHub",
href: "https://github.com/MetaMask/metamask-extension/",
},
{
label: "Snaps GitHub",
href: "https://github.com/MetaMask/snaps-monorepo",
},
],
},
{
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 cookie</button>",
},
],
},
],
copyright: `© ${new Date().getFullYear()} MetaMask • A Consensys Formation`,
},
prism: {
theme: codeTheme,
additionalLanguages: ["csharp","swift"],
},
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
},
}),
};
module.exports = config;