forked from MetaMask/metamask-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement docusaurus for MetaMask
- Loading branch information
0 parents
commit 050557a
Showing
33 changed files
with
12,658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"extends": [ | ||
"plugin:@docusaurus/recommended", | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"plugins": [ | ||
"@docusaurus", | ||
"react", | ||
"@typescript-eslint", | ||
"eslint-plugin-unused-imports" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"jsx-quotes": [ | ||
"error", | ||
"prefer-double" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"react/react-in-jsx-scope": 0, | ||
"object-curly-spacing": ["error", "always"], | ||
"comma-dangle": ["error", "always-multiline"], | ||
"no-unused-vars": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"unused-imports/no-unused-vars": [ | ||
"error", | ||
{ | ||
"vars": "all", | ||
"varsIgnorePattern": "^_", | ||
"args": "after-used", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"object-shorthand": ["error", "properties"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"eslint.format.enable": true, | ||
"eslint.packageManager": "yarn", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"eslint.codeActionsOnSave.mode": "all", | ||
"editor.tabSize": 2, | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"typescript.preferences.importModuleSpecifier": "non-relative" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# MetaMask Docs | ||
|
||
This is the MetaMask documentation repo. It's built on [Docusaurus](https://docusaurus.io/), a static site generator purpose-built for technical documentation. | ||
|
||
## Features | ||
|
||
Our instance of Docusaurus uses multiple of its powerful features, including: | ||
|
||
* [Multi-instance](https://docusaurus.io/docs/docs-multi-instance): we have two instances of docs, one for the API & SDK, and one for Snaps | ||
* [Versioning](https://docusaurus.io/docs/versioning): the Snaps documentation is exposed in two versions, "current" and "next". This allows us to send developers to either of these two versions based on whether they're using a nightly build of Flask, or the officially published extension | ||
* [MDX](https://docusaurus.io/docs/markdown-features/react#importing-markdown) | ||
* [Custom Sidebars](https://docusaurus.io/docs/sidebar): normally sidebars are auto-generated based on the docs directory structure. Having a custom sidebar allows us to define the order and inclusion of documentation items, with any hierarchy we want. The current proposed hierarchy is here: https://docs.google.com/spreadsheets/d/1fr1qnP830Zrdbzq0rPvoTVQsYBwL2Sq-wEJjL4tGfM8/edit | ||
|
||
## MDX | ||
|
||
### Tabs | ||
Tabs are documented here: https://docusaurus.io/docs/markdown-features/tabs | ||
|
||
#### Markdown in Tabs | ||
One thing that's not documented is how to properly do Markdown inside tabs. For example, to properly embed a list inside a tab item, one has to skip lines around the JSX tags, and un-indent the list. Otherwise, the 4 spaces will be mistaken as the start of a pre-formatted block: | ||
|
||
```jsx | ||
<Tabs> | ||
<TabItem value="apple" label="Apple" default> | ||
|
||
- This is a markdown apple 🍎 | ||
- This is **meow** | ||
|
||
|
||
</TabItem> {/* notice **two** skipped lines above*/} | ||
<TabItem value="orange" label="Orange"> | ||
This is an orange 🍊 | ||
</TabItem> | ||
<TabItem value="banana" label="Banana"> | ||
This is a banana 🍌 | ||
</TabItem> | ||
</Tabs> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Integrate with MetaMask (API & SDK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// @ts-check | ||
// Note: type annotations allow type checking and IDEs autocompletion | ||
|
||
const codeTheme = require("prism-react-renderer/themes/dracula"); | ||
|
||
/** @type {import('@docusaurus/types').Config} */ | ||
const config = { | ||
title: "MetaMask Docs", | ||
// tagline: '', | ||
url: "https://your-docusaurus-test-site.com", | ||
baseUrl: "/", | ||
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: "facebook", // Usually your GitHub org/user name. | ||
projectName: "docusaurus", // 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"], | ||
}, | ||
|
||
presets: [ | ||
[ | ||
"classic", | ||
/** @type {import('@docusaurus/preset-classic').Options} */ | ||
({ | ||
docs: { | ||
path: "docs", | ||
sidebarCollapsible: false, | ||
}, | ||
theme: { | ||
customCss: require.resolve("./src/css/custom.css"), | ||
}, | ||
}), | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
"content-docs", | ||
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */ | ||
({ | ||
id: "snaps", | ||
path: "snaps", | ||
routeBasePath: "snaps", | ||
sidebarPath: require.resolve("./snaps-sidebars.js"), | ||
sidebarCollapsible: false, | ||
versions: { | ||
production: { | ||
label: "Current", | ||
badge: false, | ||
}, | ||
}, | ||
}), | ||
], | ||
], | ||
themeConfig: | ||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */ | ||
({ | ||
navbar: { | ||
title: "MetaMask Docs", | ||
logo: { | ||
alt: "My Site Logo", | ||
src: "img/metamask-fox.svg", | ||
}, | ||
items: [ | ||
{ | ||
type: "doc", | ||
docId: "index", | ||
label: "SDK & API", | ||
}, | ||
{ | ||
type: "doc", | ||
docId: "index", | ||
docsPluginId: "snaps", | ||
label: "Snaps", | ||
}, | ||
], | ||
}, | ||
footer: {}, | ||
prism: { | ||
theme: codeTheme, | ||
}, | ||
}), | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "mm-docs-v-2", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"docusaurus": "docusaurus", | ||
"start": "docusaurus start", | ||
"build": "docusaurus build", | ||
"swizzle": "docusaurus swizzle", | ||
"deploy": "docusaurus deploy", | ||
"clear": "docusaurus clear", | ||
"serve": "docusaurus serve", | ||
"write-translations": "docusaurus write-translations", | ||
"write-heading-ids": "docusaurus write-heading-ids", | ||
"typecheck": "tsc" | ||
}, | ||
"dependencies": { | ||
"@docusaurus/core": "2.2.0", | ||
"@docusaurus/preset-classic": "2.2.0", | ||
"@mdx-js/react": "^1.6.22", | ||
"clsx": "^1.2.1", | ||
"prism-react-renderer": "^1.3.5", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2" | ||
}, | ||
"devDependencies": { | ||
"@docusaurus/eslint-plugin": "^2.2.0", | ||
"@docusaurus/module-type-aliases": "2.2.0", | ||
"@tsconfig/docusaurus": "^1.0.5", | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.41.0", | ||
"eslint": "^8.26.0", | ||
"eslint-plugin-react": "^7.31.10", | ||
"eslint-plugin-unused-imports": "^2.0.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.5%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"engines": { | ||
"node": ">=16.14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @ts-check | ||
|
||
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ | ||
const sidebars = { | ||
docsSidebar: [{type: 'autogenerated', dirName: '.'}], | ||
}; | ||
|
||
module.exports = sidebars; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Creating a sidebar enables you to: | ||
- create an ordered group of docs | ||
- render a sidebar for each doc of that group | ||
- provide next/previous navigation | ||
The sidebars can be generated from the filesystem, or explicitly defined here. | ||
Create as many sidebars as you want. | ||
*/ | ||
|
||
// @ts-check | ||
|
||
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ | ||
const sidebars = { | ||
// By default, Docusaurus generates a sidebar from the docs folder structure | ||
// snapsSidebar: [{type: 'autogenerated', dirName: '.'}], | ||
|
||
// But you can create a sidebar manually | ||
snapsSidebar: [ | ||
'index', | ||
{ | ||
type: "category", | ||
label: "How To", | ||
link: { type: "generated-index" }, | ||
items: [ | ||
"how-to/guide", | ||
"how-to/patching-dependencies", | ||
] | ||
}, | ||
{ | ||
type: "category", | ||
label: "Reference", | ||
link: { type: "generated-index" }, | ||
items: [ | ||
"reference/rpc-api", | ||
"reference/permissions", | ||
"reference/exports" | ||
] | ||
} | ||
] | ||
}; | ||
|
||
module.exports = sidebars; |
Oops, something went wrong.