diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index c9ec090118bd..6c48eda2b2d1 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -1,5 +1,107 @@ # Docusaurus 2 Changelog +## 2.0.0-alpha.66 (2020-10-19) + +#### :rocket: New Feature + +- `docusaurus-plugin-content-blog`, `docusaurus-theme-classic` + - [#3593](https://github.com/facebook/docusaurus/pull/3593) feat(v2): blog sidebar ([@slorber](https://github.com/slorber)) +- `docusaurus-mdx-loader`, `docusaurus-remark-plugin-npm2yarn` + - [#3469](https://github.com/facebook/docusaurus/pull/3469) feat(v2): Extract npm2yarn plugin ([@fanny](https://github.com/fanny)) +- `docusaurus-plugin-content-docs`, `docusaurus-theme-classic`, `docusaurus-theme-search-algolia` + - [#3550](https://github.com/facebook/docusaurus/pull/3550) feat(v2): contextual search, dynamic Algolia facetFilters ([@slorber](https://github.com/slorber)) +- `docusaurus-theme-classic` + - [#3580](https://github.com/facebook/docusaurus/pull/3580) feat(v2): allow to define custom CSS class for Tabs component ([@Simek](https://github.com/Simek)) + - [#3553](https://github.com/facebook/docusaurus/pull/3553) feat(v2): make dropdown menu collapsible on mobiles ([@lex111](https://github.com/lex111)) +- `docusaurus-migrate`, `docusaurus-types`, `docusaurus` + - [#3573](https://github.com/facebook/docusaurus/pull/3573) feat(v2): Add themeConfig.noIndex option #3528 ([@hamzahamidi](https://github.com/hamzahamidi)) +- `docusaurus-plugin-content-docs`, `docusaurus-theme-classic`, `docusaurus` + - [#3543](https://github.com/facebook/docusaurus/pull/3543) feat(v2): persist docs preferred version ([@slorber](https://github.com/slorber)) +- `docusaurus-theme-classic`, `docusaurus` + - [#3548](https://github.com/facebook/docusaurus/pull/3548) feat(v2): version dropdown before/after items + move site "All Versions" link ([@slorber](https://github.com/slorber)) +- `docusaurus-types`, `docusaurus` + - [#3545](https://github.com/facebook/docusaurus/pull/3545) feat(v2): site client modules ([@slorber](https://github.com/slorber)) +- `docusaurus-plugin-content-docs`, `docusaurus-theme-classic` + - [#3539](https://github.com/facebook/docusaurus/pull/3539) feat(v2): doc navbar item type ([@slorber](https://github.com/slorber)) + +#### :boom: Breaking Change + +- `docusaurus-plugin-content-docs`, `docusaurus-theme-classic`, `docusaurus-theme-search-algolia` + - [#3550](https://github.com/facebook/docusaurus/pull/3550) feat(v2): contextual search, dynamic Algolia facetFilters ([@slorber](https://github.com/slorber)) + +#### :bug: Bug Fix + +- `docusaurus-theme-classic`, `docusaurus` + - [#3607](https://github.com/facebook/docusaurus/pull/3607) fix(v2): fix error with required href attr of link in mobiles ([@lex111](https://github.com/lex111)) +- `docusaurus-theme-classic` + - [#3602](https://github.com/facebook/docusaurus/pull/3602) fix(v2): make dropdown button clickable with mouse ([@lex111](https://github.com/lex111)) + - [#3601](https://github.com/facebook/docusaurus/pull/3601) fix(v2): fix table-of-content scroll highlighting issues ([@slorber](https://github.com/slorber)) +- `docusaurus-theme-bootstrap`, `docusaurus-theme-classic` + - [#3599](https://github.com/facebook/docusaurus/pull/3599) fix(v2): remove event listeners on Tabs component unmount ([@lex111](https://github.com/lex111)) +- `docusaurus-types`, `docusaurus` + - [#3531](https://github.com/facebook/docusaurus/pull/3531) fix(v2): Fixes serve cli --port option ([@UmairKamran](https://github.com/UmairKamran)) + +#### :nail_care: Polish + +- `docusaurus-theme-classic` + - [#3585](https://github.com/facebook/docusaurus/pull/3585) refactor(v2): various dropdown improvements ([@lex111](https://github.com/lex111)) + - [#3588](https://github.com/facebook/docusaurus/pull/3588) refactor(v2): make accessible copy code button from keyboard ([@lex111](https://github.com/lex111)) + - [#3578](https://github.com/facebook/docusaurus/pull/3578) refactor(v2): apply common behavior to dropdowns ([@lex111](https://github.com/lex111)) + - [#3546](https://github.com/facebook/docusaurus/pull/3546) docs: various fixes and improvements ([@lex111](https://github.com/lex111)) +- `docusaurus-theme-classic`, `docusaurus` + - [#3587](https://github.com/facebook/docusaurus/pull/3587) refactor(v2): various fixes ([@lex111](https://github.com/lex111)) +- `docusaurus` + - [#3569](https://github.com/facebook/docusaurus/pull/3569) refactor(v2): improve broken links error message ([@slorber](https://github.com/slorber)) + +#### :memo: Documentation + +- Other + - [#3576](https://github.com/facebook/docusaurus/pull/3576) docs(v2): removed obsolete "you" identifier ([@christian-bromann](https://github.com/christian-bromann)) + - [#3589](https://github.com/facebook/docusaurus/pull/3589) docs(v2): add taro to users ([@honlyHuang](https://github.com/honlyHuang)) + - [#3565](https://github.com/facebook/docusaurus/pull/3565) docs(v2): deployment, add required Github token scope infos ([@russtaylor](https://github.com/russtaylor)) + - [#3574](https://github.com/facebook/docusaurus/pull/3574) docs(v2): adding vue-nodegui to users ([@shubhamzanwar](https://github.com/shubhamzanwar)) + - [#3556](https://github.com/facebook/docusaurus/pull/3556) Added Axioms to users ([@abhishektiwari](https://github.com/abhishektiwari)) + - [#3558](https://github.com/facebook/docusaurus/pull/3558) docs(v2): embedding real source code in MDX as a code block ([@slorber](https://github.com/slorber)) + - [#3555](https://github.com/facebook/docusaurus/pull/3555) docs(v2): add "Wisdom" dev docs website to showcase. ([@jagracey](https://github.com/jagracey)) + - [#3532](https://github.com/facebook/docusaurus/pull/3532) docs(v2): change package name in example script ([@MatanBobi](https://github.com/MatanBobi)) + - [#3538](https://github.com/facebook/docusaurus/pull/3538) docs(v1): added drone for 1.0 #3491 ([@aakhtar3](https://github.com/aakhtar3)) + - [#3533](https://github.com/facebook/docusaurus/pull/3533) docs(v1): Fix broken link in the documentation ([@saintmalik](https://github.com/saintmalik)) + - [#3534](https://github.com/facebook/docusaurus/pull/3534) docs(v2): Fix url bugs in v2 docs ([@saintmalik](https://github.com/saintmalik)) +- `docusaurus-theme-classic` + - [#3546](https://github.com/facebook/docusaurus/pull/3546) docs: various fixes and improvements ([@lex111](https://github.com/lex111)) + +#### :house: Internal + +- `docusaurus-theme-search-algolia` + - [#3591](https://github.com/facebook/docusaurus/pull/3591) chore(v2): enable new contextual search feature ([@slorber](https://github.com/slorber)) +- Other + - [#3586](https://github.com/facebook/docusaurus/pull/3586) chore(v2): fix/upgrade react types ([@slorber](https://github.com/slorber)) + - [#3577](https://github.com/facebook/docusaurus/pull/3577) refactor(v2): clarify versions page ([@lex111](https://github.com/lex111)) + - [#3560](https://github.com/facebook/docusaurus/pull/3560) feat(v2): prevent using remote image urls in showcase ([@slorber](https://github.com/slorber)) + - [#3554](https://github.com/facebook/docusaurus/pull/3554) fix(v2): use absolute path to manifest file ([@lex111](https://github.com/lex111)) +- `docusaurus-theme-classic` + - [#3394](https://github.com/facebook/docusaurus/pull/3394) refactor(v2): add useThemeConfig hook + cleanup useless theme default values ([@imskr](https://github.com/imskr)) + +#### Committers: 17 + +- Abhishek Tiwari ([@abhishektiwari](https://github.com/abhishektiwari)) +- Alexey Pyltsyn ([@lex111](https://github.com/lex111)) +- Bartosz Kaszubowski ([@Simek](https://github.com/Simek)) +- Christian Bromann ([@christian-bromann](https://github.com/christian-bromann)) +- Fanny ([@fanny](https://github.com/fanny)) +- Hamza Hamidi ([@hamzahamidi](https://github.com/hamzahamidi)) +- John Gracey ([@jagracey](https://github.com/jagracey)) +- Matan Borenkraout ([@MatanBobi](https://github.com/MatanBobi)) +- Russ Taylor ([@russtaylor](https://github.com/russtaylor)) +- SaintMalik ([@saintmalik](https://github.com/saintmalik)) +- Shubham Kumar ([@imskr](https://github.com/imskr)) +- Shubham Zanwar ([@shubhamzanwar](https://github.com/shubhamzanwar)) +- Sébastien Lorber ([@slorber](https://github.com/slorber)) +- Umair Kamran ([@UmairKamran](https://github.com/UmairKamran)) +- Utkarsh Goel ([@utkarsh867](https://github.com/utkarsh867)) +- [@aakhtar3](https://github.com/aakhtar3) +- honlyHuang ([@honlyHuang](https://github.com/honlyHuang)) + ## 2.0.0-alpha.65 (2020-10-02) #### :rocket: New Feature diff --git a/admin/publish.md b/admin/publish.md index ecbdb0cffa69..4c7cb5942de0 100644 --- a/admin/publish.md +++ b/admin/publish.md @@ -71,6 +71,8 @@ If there are no errors, you can start preparing for the new release. The changelog uses GitHub labels to classify each pull request. Use the GitHub interface to assign each newly merged pull request to a GitHub label starting with `tag:`, otherwise the PR won't appear in the changelog. +[Check tags of all recently merged Pull-Requests](https://github.com/facebook/docusaurus/pulls?q=is%3Apr+sort%3Aupdated-desc+is%3Amerged+) + The `tag:` label prefix is for PRs only. Other labels are not used by the changelog tool, and it's not necessary to assign such labels to issues, only PRs. Generate a GitHub auth token by going to https://github.com/settings/tokens (the only permission needed is `public_repo`). Save the token somewhere for future reference. @@ -94,7 +96,7 @@ Copy the generated contents and paste them in `CHANGELOG-2.x.md`. Adding the `--from` options seems to help: ```sh -yarn changelog --from v2.0.0-alpha.60` +yarn changelog --from v2.0.0-alpha.60 ``` ### 4. Cut a new version of the docs diff --git a/lerna.json b/lerna.json index 020ea9890961..2e851f76dc50 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "npmClient": "yarn", "useWorkspaces": true, "changelog": { diff --git a/packages/docusaurus-1.x/package.json b/packages/docusaurus-1.x/package.json index 60eb8c21572e..19c25c4e99e0 100644 --- a/packages/docusaurus-1.x/package.json +++ b/packages/docusaurus-1.x/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus", "description": "Easy to Maintain Open Source Documentation Websites", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "license": "MIT", "keywords": [ "documentation", diff --git a/packages/docusaurus-init-1.x/package.json b/packages/docusaurus-init-1.x/package.json index 2b420f4fd1f6..084d4c923350 100644 --- a/packages/docusaurus-init-1.x/package.json +++ b/packages/docusaurus-init-1.x/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus-init", "description": "Initialization script for Docusaurus", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "license": "MIT", "preferGlobal": true, "keywords": [ diff --git a/packages/docusaurus-init/package.json b/packages/docusaurus-init/package.json index 38bdabc0dc32..b40d3440f381 100644 --- a/packages/docusaurus-init/package.json +++ b/packages/docusaurus-init/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/init", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Create Docusaurus app easily", "repository": { "type": "git", diff --git a/packages/docusaurus-init/templates/bootstrap/package.json b/packages/docusaurus-init/templates/bootstrap/package.json index eba3c32158f6..72e983b5b1d8 100644 --- a/packages/docusaurus-init/templates/bootstrap/package.json +++ b/packages/docusaurus-init/templates/bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-2-bootstrap-template", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "private": true, "scripts": { "docusaurus": "docusaurus", @@ -11,8 +11,8 @@ "serve": "docusaurus serve" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/preset-bootstrap": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/preset-bootstrap": "2.0.0-alpha.66", "@mdx-js/react": "^1.5.8", "classnames": "^2.2.6", "react": "^16.8.4", diff --git a/packages/docusaurus-init/templates/classic/package.json b/packages/docusaurus-init/templates/classic/package.json index a7df3e964f3b..d44372bf5d24 100644 --- a/packages/docusaurus-init/templates/classic/package.json +++ b/packages/docusaurus-init/templates/classic/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-2-classic-template", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "private": true, "scripts": { "docusaurus": "docusaurus", @@ -11,8 +11,8 @@ "serve": "docusaurus serve" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/preset-classic": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/preset-classic": "2.0.0-alpha.66", "@mdx-js/react": "^1.5.8", "clsx": "^1.1.1", "react": "^16.8.4", diff --git a/packages/docusaurus-init/templates/facebook/package.json b/packages/docusaurus-init/templates/facebook/package.json index 9cd3c41ac8f9..b1bad56e223d 100644 --- a/packages/docusaurus-init/templates/facebook/package.json +++ b/packages/docusaurus-init/templates/facebook/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-2-facebook-template", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "private": true, "scripts": { "docusaurus": "docusaurus", @@ -15,8 +15,8 @@ "prettier:diff": "prettier --config .prettierrc --list-different \"**/*.{js,md}\"" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/preset-classic": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/preset-classic": "2.0.0-alpha.66", "@mdx-js/react": "^1.5.8", "clsx": "^1.1.1", "react": "^16.8.4", diff --git a/packages/docusaurus-mdx-loader/package.json b/packages/docusaurus-mdx-loader/package.json index 5510268a9ee8..22b54f71df1f 100644 --- a/packages/docusaurus-mdx-loader/package.json +++ b/packages/docusaurus-mdx-loader/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/mdx-loader", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docusaurus Loader for MDX", "main": "src/index.js", "publishConfig": { @@ -13,8 +13,8 @@ "dependencies": { "@babel/parser": "^7.9.4", "@babel/traverse": "^7.9.0", - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", "@mdx-js/mdx": "^1.5.8", "@mdx-js/react": "^1.5.8", "escape-html": "^1.0.3", @@ -30,7 +30,7 @@ "url-loader": "^4.1.0" }, "devDependencies": { - "@docusaurus/types": "2.0.0-alpha.65", + "@docusaurus/types": "2.0.0-alpha.66", "remark": "^12.0.0", "remark-mdx": "^1.5.8", "to-vfile": "^6.0.0", diff --git a/packages/docusaurus-migrate/package.json b/packages/docusaurus-migrate/package.json index 4741a0b04843..5db1ed779674 100644 --- a/packages/docusaurus-migrate/package.json +++ b/packages/docusaurus-migrate/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/migrate", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "A cli tool to migrate between different version of docusuarus", "main": "lib/index.js", "license": "MIT", diff --git a/packages/docusaurus-module-type-aliases/package.json b/packages/docusaurus-module-type-aliases/package.json index 58637590cc49..2ae61c311afb 100644 --- a/packages/docusaurus-module-type-aliases/package.json +++ b/packages/docusaurus-module-type-aliases/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/module-type-aliases", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docusaurus module type aliases", "types": "./src/index.d.ts", "publishConfig": { diff --git a/packages/docusaurus-plugin-client-redirects/package.json b/packages/docusaurus-plugin-client-redirects/package.json index 879ba0047097..e77331d93778 100644 --- a/packages/docusaurus-plugin-client-redirects/package.json +++ b/packages/docusaurus-plugin-client-redirects/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-client-redirects", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Client redirects plugin for Docusaurus", "main": "lib/index.js", "scripts": { @@ -12,10 +12,10 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@hapi/joi": "^17.1.1", "@types/hapi__joi": "^17.1.2", "chalk": "^3.0.0", diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json index 8be0e5e3cb18..5d454dc858ef 100644 --- a/packages/docusaurus-plugin-content-blog/package.json +++ b/packages/docusaurus-plugin-content-blog/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-content-blog", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Blog plugin for Docusaurus", "main": "lib/index.js", "types": "index.d.ts", @@ -16,11 +16,11 @@ "@types/hapi__joi": "^17.1.2" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/mdx-loader": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/mdx-loader": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@hapi/joi": "^17.1.1", "chalk": "^3.0.0", "feed": "^4.1.0", diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index 8e17250e00f2..e886df63d077 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-content-docs", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docs content plugin for Docusaurus", "main": "lib/index.js", "types": "src/plugin-content-docs.d.ts", @@ -13,18 +13,18 @@ }, "license": "MIT", "devDependencies": { - "@docusaurus/module-type-aliases": "2.0.0-alpha.65", + "@docusaurus/module-type-aliases": "2.0.0-alpha.66", "@types/hapi__joi": "^17.1.2", "@types/picomatch": "^2.2.1", "commander": "^5.0.0", "picomatch": "^2.1.1" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/mdx-loader": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/mdx-loader": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@hapi/joi": "17.1.1", "chalk": "^3.0.0", "execa": "^3.4.0", diff --git a/packages/docusaurus-plugin-content-pages/package.json b/packages/docusaurus-plugin-content-pages/package.json index 153205a3433d..55b40437e344 100644 --- a/packages/docusaurus-plugin-content-pages/package.json +++ b/packages/docusaurus-plugin-content-pages/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-content-pages", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Pages content plugin for Docusaurus", "main": "lib/index.js", "types": "src/plugin-content-pages.d.ts", @@ -16,11 +16,11 @@ "@types/hapi__joi": "^17.1.2" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/mdx-loader": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/mdx-loader": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@hapi/joi": "17.1.1", "globby": "^10.0.1", "loader-utils": "^1.2.3", diff --git a/packages/docusaurus-plugin-debug/package.json b/packages/docusaurus-plugin-debug/package.json index b48f50016f83..dd7db2dbe40e 100644 --- a/packages/docusaurus-plugin-debug/package.json +++ b/packages/docusaurus-plugin-debug/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-debug", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Debug plugin for Docusaurus", "main": "lib/index.js", "scripts": { @@ -12,9 +12,9 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", "react-json-view": "^1.19.1" }, "peerDependencies": { diff --git a/packages/docusaurus-plugin-google-analytics/package.json b/packages/docusaurus-plugin-google-analytics/package.json index dbc03ddef0c0..01f3b6f4dec6 100644 --- a/packages/docusaurus-plugin-google-analytics/package.json +++ b/packages/docusaurus-plugin-google-analytics/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-google-analytics", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Global analytics (analytics.js) plugin for Docusaurus", "main": "src/index.js", "publishConfig": { @@ -8,7 +8,7 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65" + "@docusaurus/core": "2.0.0-alpha.66" }, "engines": { "node": ">=10.15.1" diff --git a/packages/docusaurus-plugin-google-gtag/package.json b/packages/docusaurus-plugin-google-gtag/package.json index 0dbc6f75dc01..ccac8db4435a 100644 --- a/packages/docusaurus-plugin-google-gtag/package.json +++ b/packages/docusaurus-plugin-google-gtag/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-google-gtag", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Global Site Tag (gtag.js) plugin for Docusaurus", "main": "src/index.js", "publishConfig": { @@ -8,7 +8,7 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65" + "@docusaurus/core": "2.0.0-alpha.66" }, "engines": { "node": ">=10.15.1" diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index 056c3217a546..b2b3dcdc430d 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-ideal-image", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder)", "main": "lib/index.js", "scripts": { @@ -15,9 +15,9 @@ "fs-extra": "^9.0.0" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/lqip-loader": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/lqip-loader": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", "@endiliey/react-ideal-image": "^0.0.11", "@endiliey/responsive-loader": "^1.3.2", "react-waypoint": "^9.0.2", diff --git a/packages/docusaurus-plugin-pwa/package.json b/packages/docusaurus-plugin-pwa/package.json index 89ae442f5f5c..914b8d57ed96 100644 --- a/packages/docusaurus-plugin-pwa/package.json +++ b/packages/docusaurus-plugin-pwa/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-pwa", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docusaurus Plugin to add PWA support", "main": "src/index.js", "publishConfig": { @@ -11,7 +11,7 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.1", "@babel/plugin-proposal-optional-chaining": "^7.10.3", "@babel/preset-env": "^7.9.0", - "@docusaurus/core": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", "@hapi/joi": "^17.1.1", "babel-loader": "^8.1.0", "clsx": "^1.1.1", diff --git a/packages/docusaurus-plugin-sitemap/package.json b/packages/docusaurus-plugin-sitemap/package.json index 4c6eaf306d05..0aaae735c24b 100644 --- a/packages/docusaurus-plugin-sitemap/package.json +++ b/packages/docusaurus-plugin-sitemap/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-sitemap", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Simple sitemap generation plugin for Docusaurus", "main": "lib/index.js", "scripts": { @@ -15,8 +15,8 @@ "@types/hapi__joi": "^17.1.2" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", "@hapi/joi": "17.1.1", "fs-extra": "^8.1.0", "sitemap": "^3.2.2" diff --git a/packages/docusaurus-preset-bootstrap/package.json b/packages/docusaurus-preset-bootstrap/package.json index a3481f4eb807..ef8a232eb4c0 100644 --- a/packages/docusaurus-preset-bootstrap/package.json +++ b/packages/docusaurus-preset-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/preset-bootstrap", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Preset for bootstrap Docusaurus", "main": "src/index.js", "license": "MIT", @@ -8,11 +8,11 @@ "access": "public" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/plugin-content-blog": "2.0.0-alpha.65", - "@docusaurus/plugin-content-docs": "2.0.0-alpha.65", - "@docusaurus/plugin-content-pages": "2.0.0-alpha.65", - "@docusaurus/theme-bootstrap": "2.0.0-alpha.65" + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/plugin-content-blog": "2.0.0-alpha.66", + "@docusaurus/plugin-content-docs": "2.0.0-alpha.66", + "@docusaurus/plugin-content-pages": "2.0.0-alpha.66", + "@docusaurus/theme-bootstrap": "2.0.0-alpha.66" }, "peerDependencies": { "react": "^16.8.4", diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json index 90a9b1e29285..c9c140c925c6 100644 --- a/packages/docusaurus-preset-classic/package.json +++ b/packages/docusaurus-preset-classic/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/preset-classic", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Preset for classic Docusaurus", "main": "src/index.js", "publishConfig": { @@ -8,16 +8,16 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/plugin-content-blog": "2.0.0-alpha.65", - "@docusaurus/plugin-content-docs": "2.0.0-alpha.65", - "@docusaurus/plugin-content-pages": "2.0.0-alpha.65", - "@docusaurus/plugin-debug": "2.0.0-alpha.65", - "@docusaurus/plugin-google-analytics": "2.0.0-alpha.65", - "@docusaurus/plugin-google-gtag": "2.0.0-alpha.65", - "@docusaurus/plugin-sitemap": "2.0.0-alpha.65", - "@docusaurus/theme-classic": "2.0.0-alpha.65", - "@docusaurus/theme-search-algolia": "2.0.0-alpha.65" + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/plugin-content-blog": "2.0.0-alpha.66", + "@docusaurus/plugin-content-docs": "2.0.0-alpha.66", + "@docusaurus/plugin-content-pages": "2.0.0-alpha.66", + "@docusaurus/plugin-debug": "2.0.0-alpha.66", + "@docusaurus/plugin-google-analytics": "2.0.0-alpha.66", + "@docusaurus/plugin-google-gtag": "2.0.0-alpha.66", + "@docusaurus/plugin-sitemap": "2.0.0-alpha.66", + "@docusaurus/theme-classic": "2.0.0-alpha.66", + "@docusaurus/theme-search-algolia": "2.0.0-alpha.66" }, "peerDependencies": { "react": "^16.8.4", diff --git a/packages/docusaurus-remark-plugin-npm2yarn/package.json b/packages/docusaurus-remark-plugin-npm2yarn/package.json index 65860934dd97..c90142330170 100644 --- a/packages/docusaurus-remark-plugin-npm2yarn/package.json +++ b/packages/docusaurus-remark-plugin-npm2yarn/package.json @@ -1,25 +1,25 @@ { "name": "@docusaurus/remark-plugin-npm2yarn", - "version": "2.0.0-alpha.65", - "description": "Remark plugin for convert npm commands to yarn as tabs", - "main": "src/index.js", - "publishConfig": { - "access": "public" - }, - "license": "MIT", - "dependencies": { - "npm-to-yarn": "^1.0.1" - }, - "devDependencies": { - "remark": "^12.0.0", - "remark-mdx": "^1.5.8", - "to-vfile": "^6.0.0" - }, - "peerDependencies": { - "react": "^16.8.4", - "react-dom": "^16.8.4" - }, - "engines": { - "node": ">=10.15.1" - } + "version": "2.0.0-alpha.66", + "description": "Remark plugin for convert npm commands to yarn as tabs", + "main": "src/index.js", + "publishConfig": { + "access": "public" + }, + "license": "MIT", + "dependencies": { + "npm-to-yarn": "^1.0.1" + }, + "devDependencies": { + "remark": "^12.0.0", + "remark-mdx": "^1.5.8", + "to-vfile": "^6.0.0" + }, + "peerDependencies": { + "react": "^16.8.4", + "react-dom": "^16.8.4" + }, + "engines": { + "node": ">=10.15.1" } +} diff --git a/packages/docusaurus-theme-bootstrap/package.json b/packages/docusaurus-theme-bootstrap/package.json index 222d518f7bc6..8479bc85245a 100644 --- a/packages/docusaurus-theme-bootstrap/package.json +++ b/packages/docusaurus-theme-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/theme-bootstrap", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Bootstrap theme for docusaurus", "main": "src/index.js", "types": "src/types.d.ts", @@ -9,11 +9,11 @@ "access": "public" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/plugin-content-blog": "2.0.0-alpha.65", - "@docusaurus/plugin-content-docs": "2.0.0-alpha.65", - "@docusaurus/plugin-content-pages": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/plugin-content-blog": "2.0.0-alpha.66", + "@docusaurus/plugin-content-docs": "2.0.0-alpha.66", + "@docusaurus/plugin-content-pages": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", "@mdx-js/react": "^1.5.8", "bootstrap": "^4.4.1", "classnames": "^2.2.6", @@ -22,7 +22,7 @@ "reactstrap": "^8.4.1" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.0.0-alpha.65" + "@docusaurus/module-type-aliases": "2.0.0-alpha.66" }, "scripts": { "build": "tsc --noEmit && yarn babel && yarn prettier", diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json index 56bdfbeca8a0..206a10157406 100644 --- a/packages/docusaurus-theme-classic/package.json +++ b/packages/docusaurus-theme-classic/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/theme-classic", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Classic theme for Docusaurus", "main": "src/index.js", "types": "src/types.d.ts", @@ -15,12 +15,12 @@ "prettier": "prettier --config ../../.prettierrc --write \"**/*.{js,ts}\"" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/plugin-content-blog": "2.0.0-alpha.65", - "@docusaurus/plugin-content-docs": "2.0.0-alpha.65", - "@docusaurus/plugin-content-pages": "2.0.0-alpha.65", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/plugin-content-blog": "2.0.0-alpha.66", + "@docusaurus/plugin-content-docs": "2.0.0-alpha.66", + "@docusaurus/plugin-content-pages": "2.0.0-alpha.66", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@hapi/joi": "^17.1.1", "@mdx-js/mdx": "^1.5.8", "@mdx-js/react": "^1.5.8", @@ -37,7 +37,7 @@ "react-toggle": "^4.1.1" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.0.0-alpha.65", + "@docusaurus/module-type-aliases": "2.0.0-alpha.66", "@types/hapi__joi": "^17.1.2" }, "peerDependencies": { diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index fd263ba81559..22749611131d 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/theme-live-codeblock", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Docusaurus Live CodeBlock", "main": "src/index.js", "publishConfig": { @@ -8,7 +8,7 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", "@philpl/buble": "^0.19.7", "clsx": "^1.1.1", "parse-numeric-range": "^0.0.2", diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index 91a654761011..c343040530cd 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/theme-search-algolia", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Algolia search component for Docusaurus", "main": "src/index.js", "publishConfig": { @@ -9,8 +9,8 @@ "license": "MIT", "dependencies": { "@docsearch/react": "^1.0.0-alpha.27", - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", "@hapi/joi": "^17.1.1", "algoliasearch": "^4.0.0", "algoliasearch-helper": "^3.1.1", diff --git a/packages/docusaurus-types/package.json b/packages/docusaurus-types/package.json index 8b659ca4c073..e4ef61b82597 100644 --- a/packages/docusaurus-types/package.json +++ b/packages/docusaurus-types/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/types", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Common used typings for Docusaurus packages", "main": "./src/index.js", "types": "./src/index.d.ts", diff --git a/packages/docusaurus-utils-validation/package.json b/packages/docusaurus-utils-validation/package.json index 4b8acd65a4b2..576ac5b353cb 100644 --- a/packages/docusaurus-utils-validation/package.json +++ b/packages/docusaurus-utils-validation/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/utils-validation", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Node validation utility functions for Docusaurus packages", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -16,7 +16,7 @@ "@types/hapi__joi": "^17.1.2" }, "dependencies": { - "@docusaurus/utils": "2.0.0-alpha.65", + "@docusaurus/utils": "2.0.0-alpha.66", "@hapi/joi": "17.1.1", "chalk": "^3.0.0" }, diff --git a/packages/docusaurus-utils/package.json b/packages/docusaurus-utils/package.json index 2082c6d8160d..35a71c0ab8ca 100644 --- a/packages/docusaurus-utils/package.json +++ b/packages/docusaurus-utils/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/utils", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Node utility functions for Docusaurus packages", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index 3e138a83ebc3..495cd62d547d 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -1,7 +1,7 @@ { "name": "@docusaurus/core", "description": "Easy to Maintain Open Source Documentation Websites", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "license": "MIT", "publishConfig": { "access": "public" @@ -30,7 +30,7 @@ "url": "https://github.com/facebook/docusaurus/issues" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.0.0-alpha.65", + "@docusaurus/module-type-aliases": "2.0.0-alpha.66", "@types/detect-port": "^1.3.0", "@types/hapi__joi": "^17.1.2" }, @@ -45,9 +45,9 @@ "@babel/preset-typescript": "^7.9.0", "@babel/runtime": "^7.9.2", "@babel/runtime-corejs3": "^7.10.4", - "@docusaurus/types": "2.0.0-alpha.65", - "@docusaurus/utils": "2.0.0-alpha.65", - "@docusaurus/utils-validation": "2.0.0-alpha.65", + "@docusaurus/types": "2.0.0-alpha.66", + "@docusaurus/utils": "2.0.0-alpha.66", + "@docusaurus/utils-validation": "2.0.0-alpha.66", "@endiliey/static-site-generator-webpack-plugin": "^4.0.0", "@hapi/joi": "^17.1.1", "@svgr/webpack": "^5.4.0", diff --git a/packages/lqip-loader/package.json b/packages/lqip-loader/package.json index bfea2c07f327..e7bca982b078 100644 --- a/packages/lqip-loader/package.json +++ b/packages/lqip-loader/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/lqip-loader", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "Low Quality Image Placeholders (LQIP) loader for webpack", "main": "src/index.js", "publishConfig": { diff --git a/packages/stylelint-copyright/package.json b/packages/stylelint-copyright/package.json index 7a3d6a2d449e..43230c34cf09 100644 --- a/packages/stylelint-copyright/package.json +++ b/packages/stylelint-copyright/package.json @@ -1,6 +1,6 @@ { "name": "stylelint-copyright", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "description": "stylelint plugin to check css files for a copyright header", "main": "index.js", "license": "MIT", diff --git a/website-1.x/package.json b/website-1.x/package.json index 3d8108e4ada3..3451da1caed0 100644 --- a/website-1.x/package.json +++ b/website-1.x/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-1-website", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "private": true, "scripts": { "start": "docusaurus-start", @@ -14,6 +14,6 @@ "crowdin-download": "crowdin --config ../crowdin.yaml download -b master" }, "dependencies": { - "docusaurus": "2.0.0-alpha.65" + "docusaurus": "2.0.0-alpha.66" } } diff --git a/website/package.json b/website/package.json index 0d19ae335f36..a9babbce09a4 100644 --- a/website/package.json +++ b/website/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-2-website", - "version": "2.0.0-alpha.65", + "version": "2.0.0-alpha.66", "private": true, "scripts": { "docusaurus": "docusaurus", @@ -25,13 +25,13 @@ "netlify:test": "yarn netlify:build:deployPreview && yarn netlify dev --debug" }, "dependencies": { - "@docusaurus/core": "2.0.0-alpha.65", - "@docusaurus/plugin-client-redirects": "2.0.0-alpha.65", - "@docusaurus/plugin-ideal-image": "2.0.0-alpha.65", - "@docusaurus/plugin-pwa": "2.0.0-alpha.65", - "@docusaurus/preset-classic": "2.0.0-alpha.65", - "@docusaurus/remark-plugin-npm2yarn": "2.0.0-alpha.65", - "@docusaurus/theme-live-codeblock": "2.0.0-alpha.65", + "@docusaurus/core": "2.0.0-alpha.66", + "@docusaurus/plugin-client-redirects": "2.0.0-alpha.66", + "@docusaurus/plugin-ideal-image": "2.0.0-alpha.66", + "@docusaurus/plugin-pwa": "2.0.0-alpha.66", + "@docusaurus/preset-classic": "2.0.0-alpha.66", + "@docusaurus/remark-plugin-npm2yarn": "2.0.0-alpha.66", + "@docusaurus/theme-live-codeblock": "2.0.0-alpha.66", "clsx": "^1.1.1", "color": "^3.1.2", "npm-to-yarn": "^1.0.0-2", diff --git a/website/versioned_docs/version-2.0.0-alpha.66/api/docusaurus.config.js.md b/website/versioned_docs/version-2.0.0-alpha.66/api/docusaurus.config.js.md new file mode 100644 index 000000000000..ac7ff9d5f8dd --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/api/docusaurus.config.js.md @@ -0,0 +1,418 @@ +--- +id: docusaurus.config.js +title: docusaurus.config.js +description: API reference for Docusaurus configuration file. +slug: /docusaurus.config.js +--- + +## Overview + +`docusaurus.config.js` contains configurations for your site and is placed in the root directory of your site. + +## Required fields + +### `title` + +- Type: `string` + +Title for your website. + +```js title="docusaurus.config.js" +module.exports = { + title: 'Docusaurus', +}; +``` + +### `favicon` + +- Type: `string` + +URL for site favicon. Example: + +```js title="docusaurus.config.js" +module.exports = { + favicon: 'https://v2.docusaurus.io/favicon.ico', +}; +``` + +You can also use the favicon URL relative to the `static` directory of your site. For example, your site has the following directory structure: + +```bash +. +├── README.md +├ # ... other files in root directory +└─ static + └── img + └── favicon.ico +``` + +So you can refer it like below: + +```js title="docusaurus.config.js" +module.exports = { + favicon: 'img/favicon.ico', +}; +``` + +### `url` + +- Type: `string` + +URL for your website. This can also be considered the top-level hostname. For example, `https://facebook.github.io` is the URL of https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL for https://docusaurus.io. This field is related to the [baseUrl](#baseurl) field. + +```js title="docusaurus.config.js" +module.exports = { + url: 'https://docusaurus.io', +}; +``` + +### `baseUrl` + +- Type: `string` + +Base URL for your site. This can also be considered the path after the host. For example, `/metro/` is the baseUrl of https://facebook.github.io/metro/. For URLs that have no path, the baseUrl should be set to `/`. This field is related to the [url](#url) field. + +```js title="docusaurus.config.js" +module.exports = { + baseUrl: '/', +}; +``` + +## Optional fields + +### `noIndex` + +- Type: `boolean` + +This option adds `` in pages, to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)). + +Example: + +```js title="docusaurus.config.js" +module.exports = { + noIndex: true, // Defaults to `false` +}; +``` + +### `onBrokenLinks` + +- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'` + +The behavior of Docusaurus, when it detects any broken link. + +By default, it throws an error, to ensure you never ship any broken link, but you can lower this security if needed. + +:::note + +The broken links detection is only available for a production build (`docusaurus build`). + +::: + +### `onDuplicateRoutes` + +- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'` + +The behavior of Docusaurus when it detects any [duplicate routes](/guides/creating-pages.md#duplicate-routes). + +By default, it displays a warning after you run `yarn start` or `yarn build`. + +### `tagline` + +- Type: `string` + +The tagline for your website. + +```js title="docusaurus.config.js" +module.exports = { + tagline: + 'Docusaurus makes it easy to maintain Open Source documentation websites.', +}; +``` + +### `organizationName` + +- Type: `string` + +The GitHub user or organization that owns the repository. Used by the deployment command. + +```js title="docusaurus.config.js" +module.exports = { + // Docusaurus' organization is facebook + organizationName: 'facebook', +}; +``` + +### `projectName` + +- Type: `string` + +The name of the GitHub repository. Used by the deployment command. + +```js title="docusaurus.config.js" +module.exports = { + projectName: 'docusaurus', +}; +``` + +### `githubHost` + +- Type: `string` + +The hostname of your server. Useful if you are using GitHub Enterprise. + +```js title="docusaurus.config.js" +module.exports = { + githubHost: 'github.com', +}; +``` + +### `themeConfig` + +- Type: `Object` + + + +An object containing data needed by the theme you use. + +For Docusaurus' default theme _classic_, we use `themeConfig` to customize your navbar and footer links: + +Example: + +```js title="docusaurus.config.js" +module.exports = { + themeConfig: { + colorMode: { + defaultMode: 'light', + disableSwitch: false, + respectPrefersColorScheme: true, + switchConfig: { + darkIcon: '🌙', + lightIcon: '\u2600', + // React inline style object + // see https://reactjs.org/docs/dom-elements.html#style + darkIconStyle: { + marginLeft: '2px', + }, + lightIconStyle: { + marginLeft: '1px', + }, + }, + }, + navbar: { + title: 'Site Title', + logo: { + alt: 'Site Logo', + src: 'img/logo.svg', + }, + items: [ + { + to: 'docs/docusaurus.config.js', + activeBasePath: 'docs', + label: 'docusaurus.config.js', + position: 'left', + }, + // ... other links + ], + }, + footer: { + style: 'dark', + links: [ + { + title: 'Docs', + items: [ + { + label: 'Docs', + to: 'docs/doc1', + }, + ], + }, + // ... other links + ], + logo: { + alt: 'Facebook Open Source Logo', + src: 'https://docusaurus.io/img/oss_logo.png', + }, + copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, // You can also put own HTML here + }, + }, +}; +``` + +### `plugins` + + + +- Type: `any[]` + +```js title="docusaurus.config.js" +module.exports = { + plugins: [], +}; +``` + +### `themes` + + + +- Type: `any[]` + +```js title="docusaurus.config.js" +module.exports = { + themes: [], +}; +``` + +### `presets` + + + +- Type: `any[]` + +```js title="docusaurus.config.js" +module.exports = { + presets: [], +}; +``` + +### `customFields` + +Docusaurus guards `docusaurus.config.js` from unknown fields. To add a custom field, define it on `customFields`. + +- Type: `Object` + +```js title="docusaurus.config.js" +module.exports = { + customFields: { + admin: 'endi', + superman: 'lol', + }, +}; +``` + +Attempting to add unknown field in the config will lead to error in build time: + +```bash +Error: The field(s) 'foo', 'bar' are not recognized in docusaurus.config.js +``` + +### `scripts` + +An array of scripts to load. The values can be either strings or plain objects of attribute-value maps. The ` + <% }); %> + <%~ it.postBodyTags %> + + +}; +``` + +### `stylesheets` + +An array of CSS sources to load. The values can be either strings or plain objects of attribute-value maps. The `` tags will be inserted in the HTML ``. + +- Type: `(string | Object)[]` + +Example: + +```js title="docusaurus.config.js" +module.exports = { + stylesheets: [ + // String format. + 'https://docusaurus.io/style.css', + // Object format. + { + href: 'http://mydomain.com/style.css', + type: 'text/css', + }, + ], +}; +``` + +### `titleDelimiter` + +- Type: `string` + +A string that will be used as title delimiter in the generated `` tag. + +Example: + +```js title="docusaurus.config.js" +module.exports = { + titleDelimiter: '🦖', // Defaults to `|` +}; +``` diff --git a/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-banner.png b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-banner.png new file mode 100644 index 000000000000..ebe95f5ec838 Binary files /dev/null and b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-banner.png differ diff --git a/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-pdf.pdf b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-pdf.pdf new file mode 100644 index 000000000000..188262276aa4 Binary files /dev/null and b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example-pdf.pdf differ diff --git a/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example.xyz b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example.xyz new file mode 100644 index 000000000000..188262276aa4 Binary files /dev/null and b/website/versioned_docs/version-2.0.0-alpha.66/assets/docusaurus-asset-example.xyz differ diff --git a/website/versioned_docs/version-2.0.0-alpha.66/blog.md b/website/versioned_docs/version-2.0.0-alpha.66/blog.md new file mode 100644 index 000000000000..bdca2a9f0b60 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/blog.md @@ -0,0 +1,221 @@ +--- +id: blog +title: Blog +--- + +## Initial setup + +To setup your site's blog, start by creating a `blog` directory. + +Then, add an item link to your blog within `docusaurus.config.js`: + +```js title="docusaurus.config.js" +module.exports = { + themeConfig: { + // ... + navbar: { + items: [ + // ... + // highlight-next-line + {to: 'blog', label: 'Blog', position: 'left'}, // or position: 'right' + ], + }, + }, +}; +``` + +## Adding posts + +To publish in the blog, create a file within the blog directory with a formatted name of `YYYY-MM-DD-my-blog-post-title.md`. The post date is extracted from the file name. + +For example, at `my-website/blog/2019-09-05-hello-docusaurus-v2.md`: + +```yml +--- +title: Welcome Docusaurus v2 +author: Joel Marcey +author_title: Co-creator of Docusaurus 1 +author_url: https://github.com/JoelMarcey +author_image_url: https://graph.facebook.com/611217057/picture/?height=200&width=200 +tags: [hello, docusaurus-v2] +description: This is my first post on Docusaurus 2. +image: https://i.imgur.com/mErPwqL.png +hide_table_of_contents: false +--- +Welcome to this blog. This blog is created with [**Docusaurus 2 alpha**](https://v2.docusaurus.io/). + +<!--truncate--> + +This is my first post on Docusaurus 2. + +A whole bunch of exploration to follow. +``` + +## Header options + +The only required field is `title`; however, we provide options to add author information to your blog post as well along with other options. + +- `author` - The author name to be displayed. +- `author_url` - The URL that the author's name will be linked to. This could be a GitHub, Twitter, Facebook profile URL, etc. +- `author_image_url` - The URL to the author's thumbnail image. +- `author_title` - A description of the author. +- `title` - The blog post title. +- `tags` - A list of strings to tag to your post. +- `draft` - A boolean flag to indicate that the blog post is work-in-progress and therefore should not be published yet. However, draft blog posts will be displayed during development. +- `description`: The description of your post, which will become the `<meta name="description" content="..."/>` and `<meta property="og:description" content="..."/>` in `<head>`, used by search engines. If this field is not present, it will default to the first line of the contents. +- `image`: Cover or thumbnail image that will be used when displaying the link to your post. +- `hide_table_of_contents`: Whether to hide the table of contents to the right. By default it is `false`. + +## Summary truncation + +Use the `<!--truncate-->` marker in your blog post to represent what will be shown as the summary when viewing all published blog posts. Anything above `<!--truncate-->` will be part of the summary. For example: + +```yml +--- +title: Truncation Example +--- +All these will be part of the blog post summary. + +Even this. + +<!--truncate--> + +But anything from here on down will not be. + +Not this. + +Or this. +``` + +## Feed + +You can generate RSS/ Atom feed by passing feedOptions. + +```ts +feedOptions?: { + type: 'rss' | 'atom' | 'all'; + title?: string; + description?: string; + copyright: string; + language?: string; // possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes +}; +``` + +Example usage: + +```js {8-11} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + blog: { + feedOptions: { + type: 'all', + copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, + }, + }, + }, + ], + ], +}; +``` + +Accessing the feed: + +The feed for RSS can be found at: + +```text +https://{your-domain}/blog/rss.xml +``` + +and for Atom: + +```text +https://{your-domain}/blog/atom.xml +``` + +## Advanced topics + +### Blog-only mode + +You can run your Docusaurus 2 site without a landing page and instead have your blog's post list page as the index page. Set the `routeBasePath` to be `'/'` to indicate it's the root path. + +```js {9} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + blog: { + path: './blog', + routeBasePath: '/', // Set this value to '/'. + }, + }, + ], + ], +}; +``` + +:::caution + +Don't forget to delete the existing homepage at `./src/pages/index.js` or else there will be two files mapping to the same route! + +::: + +You can also add meta description to the blog list page for better SEO: + +```js {8} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + blog: { + blogTitle: 'Docusaurus blog!', + blogDescription: 'A docusaurus powered blog!', + }, + }, + ], + ], +}; +``` + +### Multiple blogs + +By default, the classic theme assumes only one blog per website and hence includes only one instance of the blog plugin. If you would like to have multiple blogs on a single website, it's possible too! You can add another blog by specifying another blog plugin in the `plugins` option for `docusaurus.config.js`. + +Set the `routeBasePath` to the URL route that you want your second blog to be accessed on. Note that the `routeBasePath` here has to be different from the first blog or else there could be a collision of paths! Also, set `path` to the path to the directory containing your second blog's entries. + +As documented for [multi-instance plugins](./using-plugins.md#multi-instance-plugins-and-plugin-ids), you need to assign a unique id to the plugins. + +```js title="docusaurus.config.js" +module.exports = { + // ... + plugins: [ + [ + '@docusaurus/plugin-content-blog', + { + /** + * Required for any multi-instance plugin + */ + id: 'second-blog', + /** + * URL route for the blog section of your site. + * *DO NOT* include a trailing slash. + */ + routeBasePath: 'my-second-blog', + /** + * Path to data on filesystem relative to site dir. + */ + path: './my-second-blog', + }, + ], + ], +}; +``` + +As an example, we host a second blog [here](/second-blog). diff --git a/website/versioned_docs/version-2.0.0-alpha.66/cli.md b/website/versioned_docs/version-2.0.0-alpha.66/cli.md new file mode 100644 index 000000000000..3357e8739de2 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/cli.md @@ -0,0 +1,135 @@ +--- +id: cli +title: CLI +--- + +Docusaurus provides a set of scripts to help you generate, serve, and deploy your website. + +Once your website is bootstrapped, the website source will contain the Docusaurus scripts that you can invoke with your package manager: + +```json title="package.json" +{ + // ... + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "clear": "docusaurus clear" + } +} +``` + +## Docusaurus CLI commands + +Below is a list of Docusaurus CLI commands and their usages: + +<!-- TODO: init docs after the init command is implemented + +### `docusaurus init` + +The `docusaurus init` command is intended to be used with `docusaurus` installed globally: + +```shell +$ yarn global add docusaurus +# or +$ npm install --global docusaurus +``` +--> + +### `docusaurus start` + +Builds and serves a preview of your site locally with [Webpack Dev Server](https://webpack.js.org/configuration/dev-server). + +#### Options + +| Name | Default | Description | +| --- | --- | --- | +| `--port` | `3000` | Specifies the port of the dev server. | +| `--host` | `localhost` | Specify a host to use. For example, if you want your server to be accessible externally, you can use `--host 0.0.0.0`. | +| `--hot-only` | `false` | Enables Hot Module Replacement without page refresh as fallback in case of build failures. More information [here](https://webpack.js.org/configuration/dev-server/#devserverhotonly). | +| `--no-open` | `false` | Do not open automatically the page in the browser. | +| `--poll` | `false` | Use polling of files rather than watching for live reload as a fallback in environments where watching doesn't work. More information [here](https://webpack.js.org/configuration/watch/#watchoptionspoll). | + +:::important + +Please note that some functionality (for example, anchor links) will not work in development. The functionality will work as expected in production. + +::: + +### `docusaurus build` + +Compiles your site for production. + +#### Options + +| Name | Default | Description | +| --- | --- | --- | +| `--bundle-analyzer` | `false` | Analyze your bundle with the [webpack bundle analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer). | +| `--out-dir` | `build` | The full path for the new output directory, relative to the current workspace. | +| `--no-minify` | `false` | Build website without minimizing JS/CSS bundles. | + +### `docusaurus swizzle` + +:::caution + +We highly discourage swizzling of components until we've reached a Beta stage. The components APIs have been changing rapidly and are likely to keep changing until we reach Beta. Stick with the default appearance for now if possible to save yourself some potential pain in future. + +::: + +Change any Docusaurus theme components to your liking with `docusaurus swizzle`. + +```shell +docusaurus swizzle [themeName] [componentName] [siteDir] + +# Example (leaving out the siteDir to indicate this directory) +docusaurus swizzle @docusaurus/theme-classic DocSidebar +``` + +Running the command will copy the relevant theme files to your site folder. You may then make any changes to it and Docusaurus will use it instead of the one provided from the theme. + +`docusaurus swizzle` without `themeName` lists all the themes available for swizzling similarly `docusaurus swizzle <themeName>` without `componentName` lists all the components available for swizzling. + +#### Options + +| Name | Description | +| ------------------ | -------------------------------------- | +| `themeName` | The name of the theme you are using. | +| `swizzleComponent` | The name of the component to swizzle. | +| `--danger` | Allow swizzling of unstable components | +| `--typescript` | Swizzle TypeScript components | + +To unswizzle a component, simply delete the files of the swizzled component. + +<!-- +TODO a separate section for swizzle tutorial. +To learn more about swizzling, check [here](#). +--> + +### `docusaurus deploy` + +Deploys your site with [GitHub Pages](https://pages.github.com/). Check out the docs on [deployment](deployment.md/#deploying-to-github-pages) for more details. + +#### Options + +| Name | Default | Description | +| --- | --- | --- | +| `--out-dir` | `build` | The full path for the new output directory, relative to the current workspace. | +| `--skip-build` | `false` | Deploy website without building it. This may be useful when using custom deploy script. | + +### `docusaurus serve` + +Serve your built website locally. + +| Name | Default | Description | +| --- | --- | --- | +| `--port` | `3000` | Use specified port | +| `--dir` | `build` | The full path for the output directory, relative to the current workspace | +| `--build` | `false` | Build website before serving | +| `--host` | `localhost` | Specify a host to use. For example, if you want your server to be accessible externally, you can use `--host 0.0.0.0`. | + +### `docusaurus clear` + +Clear a Docusaurus site's generated assets, caches, build artifacts. + +We recommend running this command before reporting bugs, after upgrading versions, or anytime you have issues with your Docusaurus site. diff --git a/website/versioned_docs/version-2.0.0-alpha.66/configuration.md b/website/versioned_docs/version-2.0.0-alpha.66/configuration.md new file mode 100644 index 000000000000..bc4aa548643a --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/configuration.md @@ -0,0 +1,164 @@ +--- +id: configuration +title: Configuration +--- + +Docusaurus has a unique take on configurations. We encourage you to congregate information of your site into one place. We guard the fields of this file, and facilitate making this data object accessible across your site. + +Keeping a well-maintained `docusaurus.config.js` helps you, your collaborators, and your open source contributors be able to focus on documentation while still being able to customize the site. + +## What goes into a `docusaurus.config.js`? + +You should not have to write your `docusaurus.config.js` from scratch even if you are developing your site. All templates come with a `docusaurus.config.js` that includes defaults for the common options. + +However, it can be helpful if you have a high-level understanding of how the configurations are designed and implemented. + +The high-level overview of Docusaurus configuration can be categorized into: + +- [What goes into a `docusaurus.config.js`?](#what-goes-into-a-docusaurusconfigjs) + - [Site metadata](#site-metadata) + - [Deployment configurations](#deployment-configurations) + - [Theme, plugin, and preset configurations](#theme-plugin-and-preset-configurations) + - [Custom configurations](#custom-configurations) +- [Customizing Babel Configuration](#customizing-babel-configuration) + +For exact reference to each of the configurable fields, you may refer to [**`docusaurus.config.js` API reference**](api/docusaurus.config.js.md). + +### Site metadata + +Site metadata contains the essential global metadata such as `title`, `url`, `baseUrl` and `favicon`. + +They are used in a number of places such as your site's title and headings, browser tab icon, social sharing (Facebook, Twitter) information or even to generate the correct path to serve your static files. + +### Deployment configurations + +Deployment configurations such as `projectName` and `organizationName` are used when you deploy your site with the `deploy` command. + +It is recommended to check the [deployment docs](deployment.md) for more information. + +### Theme, plugin, and preset configurations + +List the [theme](using-themes.md), [plugins](using-plugins.md), and [presets](presets.md) for your site in the `themes`, `plugins`, and `presets` fields, respectively. These are typically npm packages: + +```js title="docusaurus.config.js" +module.exports = { + // ... + plugins: [ + '@docusaurus/plugin-content-blog', + '@docusaurus/plugin-content-pages', + ], + themes: ['@docusaurus/theme-classic'], +}; +``` + +They can also be loaded from local directories: + +```js title="docusaurus.config.js" +const path = require('path'); + +module.exports = { + // ... + themes: [path.resolve(__dirname, '/path/to/docusaurus-local-theme')], +}; +``` + +To specify options for a plugin or theme, replace the name of the plugin or theme in the config file with an array containing the name and an options object: + +```js title="docusaurus.config.js" +module.exports = { + // ... + plugins: [ + [ + '@docusaurus/plugin-content-blog', + { + path: 'blog', + routeBasePath: 'blog', + include: ['*.md', '*.mdx'], + // ... + }, + ], + '@docusaurus/plugin-content-pages', + ], +}; +``` + +To specify options for a plugin or theme that is bundled in a preset, pass the options through the `presets` field. In this example, `docs` refers to `@docusaurus/plugin-content-docs` and `theme` refers to `@docusaurus/theme-classic`. + +```js title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + sidebarPath: require.resolve('./sidebars.js'), + }, + theme: { + customCss: [require.resolve('./src/css/custom.css')], + }, + }, + ], + ], +}; +``` + +For further help configuring themes, plugins, and presets, see [Using Themes](using-themes.md), [Using Plugins](using-plugins.md), and [Using Presets](presets.md). + +### Custom configurations + +Docusaurus guards `docusaurus.config.js` from unknown fields. To add custom fields, define them in `customFields`. + +Example: + +```js title="docusaurus.config.js" +module.exports = { + // ... + // highlight-start + customFields: { + image: '', + keywords: [], + }, + // highlight-end + // ... +}; +``` + +## Accessing configuration from components + +Your configuration object will be made available to all the components of your site. And you may access them via React context as `siteConfig`. + +Basic example: + +```jsx +import React from 'react'; +// highlight-next-line +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; + +const Hello = () => { + // highlight-start + const {siteConfig} = useDocusaurusContext(); + // highlight-end + const {title, tagline} = siteConfig; + + return <div>{`${title} · ${tagline}`}</div>; +}; +``` + +:::tip + +If you just want to use those fields on the client side, you could create your own JS files and import them as ES6 modules, there is no need to put them in `docusaurus.config.js`. + +::: + +## Customizing Babel Configuration + +For new Docusaurus projects, we automatically generated a `babel.config.js` in project root. + +```js title="babel.config.js" +module.exports = { + presets: [require.resolve('@docusaurus/core/lib/babel/preset')], +}; +``` + +Most of the times, this configuration will work just fine. If you want to customize it, you can directly edit this file to customize babel configuration. For your changes to take effect, you need to restart Docusaurus devserver. diff --git a/website/versioned_docs/version-2.0.0-alpha.66/contributing.md b/website/versioned_docs/version-2.0.0-alpha.66/contributing.md new file mode 100644 index 000000000000..130a7f42a980 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/contributing.md @@ -0,0 +1,190 @@ +--- +id: contributing +title: Contributing +--- + +[Docusaurus 2](https://v2.docusaurus.io/) is currently under alpha development. We have [early adopters who already started using it](/showcase). We are now welcoming contributors to collaborate on the next Docusaurus. + +The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies who want to learn how to run and contribute to an open source project. Contributors and people new to open source alike will find the following guides especially useful: + +- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) +- [Building Welcoming Communities](https://opensource.guide/building-community/) + +## [Code of Conduct](https://code.fb.com/codeofconduct) + +Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated. + +## Get involved + +There are many ways to contribute to Docusaurus, and many of them do not involve writing any code. Here's a few ideas to get started: + +- Start using Docusaurus 2! Go through the [Getting Started](installation.md) guides. Does everything work as expected? If not, we're always looking for improvements. Let us know by [opening an issue](#reporting-new-issues). +- Look through the [v2.0 issues](https://github.com/facebook/docusaurus/labels/v2). If you find an issue you would like to fix, [open a pull request](#your-first-pull-request). Issues tagged as [_Good first issue_](https://github.com/facebook/docusaurus/labels/Good%20first%20issue) are a good place to get started. +- Help us making the docs better. File an issue if you find anything that is confusing or can be improved. We also have [an umbrella issue for v2 docs](https://github.com/facebook/docusaurus/issues/1640) where we are planning and working on all v2 docs. You may adopt a doc piece there to work on. +- Take a look at the [features requested](https://github.com/facebook/docusaurus/labels/enhancement) by others in the community and consider opening a pull request if you see something you want to work on. + +Contributions are very welcome. If you think you need help planning your contribution, please ping us on Twitter at [@docusaurus](https://twitter.com/docusaurus) and let us know you are looking for a bit of help. + +### Join our Discord channel + +To participate in Docusaurus 2 dev, join the [#docusaurus-2-dev](https://discord.gg/Je6Ash6) channel. + +## Our development process + +Docusaurus uses [GitHub](https://github.com/facebook/docusaurus) as its source of truth. The core team will be working directly there. All changes will be public from the beginning. + +When a change made on GitHub is approved, it will be checked by our continuous integration system, CircleCI. + +### Reporting new issues + +When [opening a new issue](https://github.com/facebook/docusaurus/issues/new/choose), always make sure to fill out the issue template. **This step is very important!** Not doing so may result in your issue not managed in a timely fashion. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template. + +- **One issue, one bug:** Please report a single bug per issue. +- **Provide reproduction steps:** List all the steps necessary to reproduce the issue. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort. + +### Reporting bugs + +We use [GitHub Issues](https://github.com/facebook/docusaurus/issues) for our public bugs. If you would like to report a problem, take a look around and see if someone already opened an issue about it. If you a are certain this is a new, unreported bug, you can submit a [bug report](#reporting-new-issues). + +If you have questions about using Docusaurus, contact the Docusaurus Twitter account at [@docusaurus](https://twitter.com/docusaurus), and we will do our best to answer your questions. + +You can also file issues as [feature requests or enhancements](https://github.com/facebook/docusaurus/labels/feature). If you see anything you'd like to be implemented, create an issue with [feature template](https://raw.githubusercontent.com/facebook/docusaurus/master/.github/ISSUE_TEMPLATE/feature.md/) + +### Reporting security bugs + +Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page. + +## Working on Docusaurus code + +### Installation + +1. Ensure you have [Yarn](https://yarnpkg.com/) installed +2. After cloning the repository, run `yarn install` in the root of the repository +3. To start a local development server serving the Docusaurus docs, go into the `website` directory and run `yarn start` + +### Semantic commit messages + +See how a minor change to your commit message style can make you a better programmer. + +Format: `<type>(<scope>): <subject>` + +`<scope>` is optional + +**Example** + +``` +feat: allow overriding of webpack config +^--^ ^------------^ +| | +| +-> Summary in present tense. +| ++-------> Type: chore, docs, feat, fix, refactor, style, or test. +``` + +The various types of commits: + +- `feat`: (new feature for the user, not a new feature for build script) +- `fix`: (bug fix for the user, not a fix to a build script) +- `docs`: (changes to the documentation) +- `style`: (formatting, missing semi colons, etc; no production code change) +- `refactor`: (refactoring production code, eg. renaming a variable) +- `test`: (adding missing tests, refactoring tests; no production code change) +- `chore`: (updating grunt tasks etc; no production code change) + +Use lower case not title case! + +### Code conventions + +#### Style guide + +[Prettier](https://prettier.io/) will catch most styling issues that may exist in your code. You can check the status of your code styling by simply running `npm run prettier`. + +However, there are still some styles that Prettier cannot pick up. + +#### General + +- **Most important: Look around.** Match the style you see used in the rest of the project. This includes formatting, naming files, naming things in code, naming things in documentation. +- "Attractive" + +#### Documentation + +- Do not wrap lines at 80 characters - configure your editor to soft-wrap when editing documentation. + +## Pull requests + +### Your first pull request + +So you have decided to contribute code back to upstream by opening a pull request. You've invested a good chunk of time, and we appreciate it. We will do our best to work with you and get the PR looked at. + +Working on your first Pull Request? You can learn how from this free video series: + +[**How to Contribute to an Open Source Project on GitHub**](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) + +We have a list of [beginner friendly issues](https://github.com/facebook/docusaurus/labels/good%20first%20issue) to help you get your feet wet in the Docusaurus codebase and familiar with our contribution process. This is a great place to get started. + +### Proposing a change + +If you would like to request a new feature or enhancement but are not yet thinking about opening a pull request, you can also file an issue with [feature template](https://github.com/facebook/docusaurus/issues/new?template=feature.md/). + +If you intend to change the public API (e.g., something in `docusaurus.config.js`), or make any non-trivial changes to the implementation, we recommend filing an issue with [proposal template](https://github.com/facebook/docusaurus/issues/new?template=proposal.md) and including `[Proposal]` in the title. This lets us reach an agreement on your proposal before you put significant effort into it. These types of issues should be rare. + +If you're only fixing a bug, it's fine to submit a pull request right away but we still recommend to file an issue detailing what you're fixing. This is helpful in case we don't accept that specific fix but want to keep track of the issue. + +### Sending a pull request + +Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it. It is recommended to follow this [commit message style](#semantic-commit-messages). + +Please make sure the following is done when submitting a pull request: + +1. Fork [the repository](https://github.com/facebook/docusaurus) and create your branch from `master`. +1. Add the copyright notice to the top of any code new files you've added. +1. Describe your [test plan](#test-plan) in your pull request description. Make sure to [test your changes](https://github.com/facebook/docusaurus/blob/master/admin/testing-changes-on-Docusaurus-itself.md/)! +1. Make sure your code lints (`yarn prettier && yarn lint`). +1. Make sure your Jest tests pass (`yarn test`). +1. If you haven't already, [sign the CLA](https://code.facebook.com/cla). + +All pull requests should be opened against the `master` branch. + +#### Test plan + +A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI. + +- If you've changed APIs, update the documentation. + +#### Breaking changes + +When adding a new breaking change, follow this template in your pull request: + +```md +### New breaking change here + +- **Who does this affect**: +- **How to migrate**: +- **Why make this breaking change**: +- **Severity (number of people affected x effort)**: +``` + +#### Copyright header for source code + +Copy and paste this to the top of your new file(s): + +```js +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +``` + +#### Contributor License Agreement (CLA) + +In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, the Facebook GitHub Bot will reply with a link to the CLA form. You may also [complete your CLA here](https://code.facebook.com/cla). + +### What happens next? + +The core Docusaurus team will be monitoring for pull requests. Do help us by keeping pull requests consistent by following the guidelines above. + +## License + +By contributing to Docusaurus, you agree that your contributions will be licensed under its MIT license. diff --git a/website/versioned_docs/version-2.0.0-alpha.66/deployment.md b/website/versioned_docs/version-2.0.0-alpha.66/deployment.md new file mode 100644 index 000000000000..3c9bd9d99a25 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/deployment.md @@ -0,0 +1,403 @@ +--- +id: deployment +title: Deployment +--- + +To build the static files of your website for production, run: + +```bash npm2yarn +npm run build +``` + +Once it finishes, the static files will be generated within the `build/` directory. + +You can deploy your site to static site hosting services such as [Vercel](https://vercel.com/), [GitHub Pages](https://pages.github.com/), [Netlify](https://www.netlify.com/), [Render](https://render.com/docs/static-sites), and [Surge](https://surge.sh/help/getting-started-with-surge). Docusaurus sites are statically rendered so they work without JavaScript too! + +## Testing Build Local + +It is important to test build before deploying to a production. Docusaurus includes a [`docusaurus serve`](cli.md#docusaurus-serve) command to test build locally. + +```bash npm2yarn +npm run serve +``` + +## Self Hosting + +:::warning + +It is not the most performant solution + +::: + +Docusaurus can be self hosted using [`docusaurus serve`](cli.md#docusaurus-serve). Change port using `--port` and `--host` to change host. + +```bash npm2yarn +npm run serve --build --port 80 --host 0.0.0.0 +``` + +## Deploying to GitHub Pages + +Docusaurus provides an easy way to publish to [GitHub Pages](https://pages.github.com/). Which is hosting that comes for free with every GitHub repository. + +### `docusaurus.config.js` settings + +First, modify your `docusaurus.config.js` and add the required params: + +| Name | Description | +| --- | --- | +| `organizationName` | The GitHub user or organization that owns the repository. If you are the owner, it is your GitHub username. In the case of Docusaurus, it is "_facebook_" which is the GitHub organization that owns Docusaurus. | +| `projectName` | The name of the GitHub repository. For example, the repository name for Docusaurus is "docusaurus", so the project name is "docusaurus". | +| `url` | URL for your GitHub Page's user/organization page. This is commonly https://_username_.github.io. | +| `baseUrl` | Base URL for your project. For projects hosted on GitHub pages, it follows the format "/_projectName_/". For https://github.com/facebook/docusaurus, `baseUrl` is `/docusaurus/`. | + +In case you want to use your custom domain for GitHub Pages, create a `CNAME` file in the `static` directory. Anything within the `static` directory will be copied to the root of the `build` directory for deployment. + +You may refer to GitHub Pages' documentation [User, Organization, and Project Pages](https://help.github.com/en/articles/user-organization-and-project-pages) for more details. + +Example: + +```jsx {3-6} title="docusaurus.config.js" +module.exports = { + // ... + url: 'https://endiliey.github.io', // Your website URL + baseUrl: '/', + projectName: 'endiliey.github.io', + organizationName: 'endiliey', + // ... +}; +``` + +:::warning + +By default, GitHub Pages runs published files through [Jekyll](https://jekyllrb.com/). Since Jekyll will discard any files that begin with `_`, it is recommended that you disable Jekyll by adding an empty file named `.nojekyll` file to your `static` directory. + +::: + +### Environment settings + +Specify the Git user as an environment variable. + +| Name | Description | +| --- | --- | +| `GIT_USER` | The username for a GitHub account that has commit access to this repo. For your own repositories, this will usually be your GitHub username. The specified `GIT_USER` must have push access to the repository specified in the combination of `organizationName` and `projectName`. | + +Optional parameters, also set as environment variables: + +| Name | Description | +| --- | --- | +| `USE_SSH` | Set to `true` to use SSH instead of the default HTTPS for the connection to the GitHub repo. | +| `DEPLOYMENT_BRANCH` | The branch that the website will be deployed to, defaults to `gh-pages` for normal repos and `master` for repository names ending in `github.io`. | +| `CURRENT_BRANCH` | The branch that contains the latest docs changes that will be deployed. Usually, the branch will be `master`, but it could be any branch (default or otherwise) except for `gh-pages`. If nothing is set for this variable, then the current branch will be used. | + +### Deploy + +Finally, to deploy your site to GitHub Pages, run: + +<Tabs defaultValue="bash" values={[ { label: 'Bash', value: 'bash', }, { label: 'Windows', value: 'windows', }, { label: 'PowerShell', value: 'powershell', },]}><TabItem value="bash"> + +```bash +GIT_USER=<GITHUB_USERNAME> yarn deploy +``` + +</TabItem> +<TabItem value="windows"> + +```batch +cmd /C "set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy" +``` + +</TabItem> +<TabItem value="powershell"> + +```powershell +cmd /C 'set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy' +``` + +</TabItem> +</Tabs> + +### Triggering deployment with GitHub Actions + +[GitHub Actions](https://help.github.com/en/actions) allow you to automate, customize, and execute your software development workflows right in your repository. + +This workflow assumes your documentation resided in `documentation` branch of your repository and your [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is configured for `gh-pages` branch. + +1. Generate a new [SSH key](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). +1. By default, your public key should have been created in `~/.ssh/id_rsa.pub` or use the name you've provided in the previous step to add your key to [GitHub deploy keys](https://developer.github.com/v3/guides/managing-deploy-keys/). +1. Copy key to clipboard with `xclip -sel clip < ~/.ssh/id_rsa.pub` and paste it as a [deploy key](https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys) in your repository. Copy file content if the command line doesn't work for you. Check the box for `Allow write access` before saving your deployment key. +1. You'll need your private key as a [GitHub secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) to allow Docusaurus to run the deployment for you. +1. Copy your private key with `xclip -sel clip < ~/.ssh/id_rsa` and paste a GitHub secret with name `GH_PAGES_DEPLOY`. Copy file content if the command line doesn't work for you. Save your secret. +1. Create you [documentation workflow file](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#creating-a-workflow-file) in `.github/workflows/`. In this example it's `documentation.yml`. + +```yaml title="documentation.yml" +name: documentation + +on: + pull_request: + branches: [documentation] + push: + branches: [documentation] + +jobs: + checks: + if: github.event_name != 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Test Build + run: | + if [ -e yarn.lock ]; then + yarn install --frozen-lockfile + elif [ -e package-lock.json ]; then + npm ci + else + npm i + fi + npm run build + gh-release: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Add key to allow access to repository + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + mkdir -p ~/.ssh + ssh-keyscan github.com >> ~/.ssh/known_hosts + echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + cat <<EOT >> ~/.ssh/config + Host github.com + HostName github.com + IdentityFile ~/.ssh/id_rsa + EOT + - name: Release to GitHub Pages + env: + USE_SSH: true + GIT_USER: git + run: | + git config --global user.email "actions@gihub.com" + git config --global user.name "gh-actions" + if [ -e yarn.lock ]; then + yarn install --frozen-lockfile + elif [ -e package-lock.json ]; then + npm ci + else + npm i + fi + npx docusaurus deploy +``` + +1. Now when a new pull request arrives towards your repository in branch `documentation` it will automatically ensure that Docusaurus build is successful. +1. When pull request is merged to `documentation` branch or someone pushes to `documentation` branch directly it will be built and deployed to `gh-pages` branch. +1. After this step, your updated documentation will be available on the GitHub pages. + +### Triggering deployment with Travis CI + +Continuous integration (CI) services are typically used to perform routine tasks whenever new commits are checked in to source control. These tasks can be any combination of running unit tests and integration tests, automating builds, publishing packages to NPM, and deploying changes to your website. All you need to do to automate the deployment of your website is to invoke the `yarn deploy` script whenever your website is updated. The following section covers how to do just that using [Travis CI](https://travis-ci.com/), a popular continuous integration service provider. + +1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). When creating the token, grant it the `repo` scope so that it has the permissions it needs. +1. Using your GitHub account, [add the Travis CI app](https://github.com/marketplace/travis-ci) to the repository you want to activate. +1. Open your Travis CI dashboard. The URL looks like https://travis-ci.com/USERNAME/REPO, and navigate to the `More options` > `Setting` > `Environment Variables` section of your repository. +1. Create a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username). +1. Create a `.travis.yml` on the root of your repository with the following: + +```yaml title=".travis.yml" +language: node_js +node_js: + - '10' +branches: + only: + - master +cache: + yarn: true +script: + - git config --global user.name "${GH_NAME}" + - git config --global user.email "${GH_EMAIL}" + - echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc + - yarn && GIT_USER="${GH_NAME}" yarn deploy +``` + +Now, whenever a new commit lands in `master`, Travis CI will run your suite of tests and if everything passes, your website will be deployed via the `yarn deploy` script. + +### Using Azure Pipelines + +1. Sign Up at [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) if you haven't already. +1. Create an organization and within the organization create a project and connect your repository from GitHub. +1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) with the `repo` scope. +1. In the project page (which looks like https://dev.azure.com/ORG_NAME/REPO_NAME/_build) create a new pipeline with the following text. Also, click on edit and add a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username). Make sure to mark them as secret. Alternatively, you can also add a file named `azure-pipelines.yml` at yout repository root. + +```yaml title="azure-pipelines.yml" +trigger: + - master + +pool: + vmImage: 'ubuntu-latest' + +steps: + - checkout: self + persistCredentials: true + + - task: NodeTool@0 + inputs: + versionSpec: '10.x' + displayName: 'Install Node.js' + + - script: | + git config --global user.name "${GH_NAME}" + git config --global user.email "${GH_EMAIL}" + git checkout -b master + echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc + yarn && GIT_USER="${GH_NAME}" yarn deploy + env: + GH_NAME: $(GH_NAME) + GH_EMAIL: $(GH_EMAIL) + GH_TOKEN: $(GH_TOKEN) + displayName: 'yarn install and build' +``` + +### Using Drone + +1. Create a new ssh key that will be the [deploy key](https://docs.github.com/en/free-pro-team@latest/developers/overview/managing-deploy-keys#deploy-keys) for your project. +1. Name your private and public keys to be specific and so that it does not overwrite your other [ssh keys](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). +1. Go to https://github.com/USERNAME/REPO/settings/keys and add a new deploy key by pasting in our public key you just generated. +1. Open your Drone.io dashboard and login. The URL looks like https://cloud.drone.io/USERNAME/REPO. +1. Click on the repository, click on activate repository, and add a secret called `git_deploy_private_key` with your private key value that you just generated. +1. Create a `.drone.yml` on the root of your repository with below text. + +```yaml +# .drone.yml +kind: pipeline +type: docker +trigger: + event: + - tag +- name: Website + image: node + commands: + - mkdir -p $HOME/.ssh + - ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts + - echo "$GITHUB_PRIVATE_KEY > $HOME/.ssh/id_rsa" + - chmod 0600 $HOME/.ssh/id_rsa + - cd website + - npm i + - npm run publish-gh-pages + environment: + USE_SSH: true + GIT_USER: $DRONE_COMMIT_AUTHOR + GITHUB_PRIVATE_KEY: git_deploy_private_key +``` + +Now, whenever you push a new tag to github, this trigger will start the drone ci job to publish your website. + +## Deploying to Netlify + +To deploy your Docusaurus 2 sites to [Netlify](https://www.netlify.com/), first make sure the following options are properly configured: + +```js {2-3} title="docusaurus.config.js" +module.exports = { + url: 'https://docusaurus-2.netlify.com', // Url to your site with no trailing slash + baseUrl: '/', // Base directory of your site relative to your repo + // ... +}; +``` + +Then, [create your site with Netlify](https://app.netlify.com/start). + +While you set up the site, specify the build commands and directories as follows: + +- build command: `npm run build` +- build directory: `build` + +If you did not configure these build options, you may still go to "Site settings" -> "Build and deploy" after your site is created. + +Once properly configured with the above options, your site should deploy and automatically redeploy upon merging to your deploy branch, which defaults to `master`. + +:::important + +Make sure to disable Netlify setting `Pretty URLs` to prevent lowercased URLs, unnecessary redirects and 404 errors. + +::: + +## Deploying to Vercel + +Deploying your Docusaurus project to [Vercel](https://vercel.com/) will provide you with [various benefits](https://vercel.com/) in the areas of performance and ease of use. + +To deploy your Docusaurus project with a [Vercel for Git Integration](https://vercel.com/docs/git-integrations), make sure it has been pushed to a Git repository. + +Import the project into Vercel using the [Import Flow](https://vercel.com/import/git). During the import, you will find all relevant options preconfigured for you; however, you can choose to change any of these options, a list of which can be found [here](https://vercel.com/docs/build-step#build-&-development-settings). + +After your project has been imported, all subsequent pushes to branches will generate [Preview Deployments](https://vercel.com/docs/platform/deployments#preview), and all changes made to the [Production Branch](https://vercel.com/docs/git-integrations#production-branch) (commonly "main") will result in a [Production Deployment](https://vercel.com/docs/platform/deployments#production). + +## Deploying to Render + +Render offers [free static site hosting](https://render.com/docs/static-sites) with fully managed SSL, custom domains, a global CDN and continuous auto-deploy from your Git repo. Deploy your app in just a few minutes by following these steps. + +1. Create a new **Web Service** on Render, and give Render permission to access your Docusaurus repo. + +1. Select the branch to deploy. The default is `master`. + +1. Enter the following values during creation. + + | Field | Value | + | --------------------- | ------------- | + | **Environment** | `Static Site` | + | **Build Command** | `yarn build` | + | **Publish Directory** | `build` | + +That's it! Your app will be live on your Render URL as soon as the build finishes. + +## Deploying to Surge + +Surge is a [static web hosting platform](https://surge.sh/help/getting-started-with-surge), it is used to deploy your Docusaurus project from the command line in a minute. Deploying your project to Surge is easy and it is also free (including a custom domain and SSL). + +Deploy your app in a matter of seconds using surge with the following steps: + +1. First, install Surge using npm by running the following command: + +```bash +npm install --g surge +``` + +2. To build the static files of your site for production in the root directory of your project, run: + +```bash +npm run build +``` + +3. Then, run this command inside the root directory of your project: + +```bash +surge build/ +``` + +First-time users of Surge would be prompted to create an account from the command line(happens only once). + +Confirm that the site you want to publish is in the `build` directory, a randomly generated subdomain `*.surge.sh subdomain` is always given (which can be edited). + +### Using your domain + +If you have a domain name you can deploy your site using surge to your domain using the command: + +```bash +surge build/ yourdomain.com +``` + +Your site is now deployed for free at `subdomain.surge.sh` or `yourdomain.com` depending on the method you chose. + +### Setting up CNAME file + +Store your domain in a CNAME file for future deployments with the following command: + +```bash +echo subdomain.surge.sh > CNAME +``` + +You can deploy any other changes in the future with the command `surge`. diff --git a/website/versioned_docs/version-2.0.0-alpha.66/design-principles.md b/website/versioned_docs/version-2.0.0-alpha.66/design-principles.md new file mode 100644 index 000000000000..8e85dbfde8ee --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/design-principles.md @@ -0,0 +1,34 @@ +--- +id: design-principles +title: Design Principles +--- + +:::caution + +This section is a work in progress. + +::: + +- **Little to learn** - Docusaurus should be easy to learn and use as the API is quite small. Most things will still be achievable by users, even if it takes them more code and more time to write. Not having abstractions is better than having the wrong abstractions, and we don't want users to have to hack around the wrong abstractions. Mandatory talk - [Minimal API Surface Area](https://www.youtube.com/watch?v=4anAwXYqLG8). +- **Intuitive** - Users will not feel overwhelmed when looking at the project directory of a Docusaurus project or adding new features. It should look intuitive and easy to build on top of, using approaches they are familiar with. +- **Layered architecture** - The separations of concerns between each layer of our stack (content/theming/styling) should be clear - well-abstracted and modular. +- **Sensible defaults** - Common and popular performance optimizations and configurations will be done for users but they are given the option to override them. +- **No vendor-lock in** - Users are not required to use the default plugins or CSS, although they are highly encouraged to. Certain core lower-level infra level pieces like React Loadable, React Router cannot be swapped because we do default performance optimization on them. But not higher level ones, such as choice of Markdown engines, CSS frameworks, CSS methodology will be entirely up to users. + +## How Docusaurus works + +<!-- moved in from how Docusaurus works @yangshun --> + +We believe that as developers, knowing how a library works is helpful in allowing us to become better at using it. Hence we're dedicating effort into explaining the architecture and various components of Docusaurus with the hope that users reading it will gain a deeper understanding of the tool and be even more proficient in using it. + +<!-- + +Explain the principles that guide the development of Docusaurus. + +References +--- +- https://www.gatsbyjs.org/docs/behind-the-scenes/ +- https://reactjs.org/docs/design-principles.html +- https://v1.vuepress.vuejs.org/miscellaneous/design-concepts.html + +--> diff --git a/website/versioned_docs/version-2.0.0-alpha.66/docs.md b/website/versioned_docs/version-2.0.0-alpha.66/docs.md new file mode 100644 index 000000000000..a46ff9c6fde6 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/docs.md @@ -0,0 +1,327 @@ +--- +id: docs-introduction +title: Docs Introduction +sidebar_label: Introduction +--- + +The docs feature provides users with a way to organize Markdown files in a hierarchical format. + +## Document ID + +Every document has a unique `id`. By default, a document `id` is the name of the document (without the extension) relative to the root docs directory. + +For example, `greeting.md` id is `greeting` and `guide/hello.md` id is `guide/hello`. + +```bash +website # Root directory of your site +└── docs +   ├── greeting.md + └── guide + └── hello.md +``` + +However, the **last part** of the `id` can be defined by user in the front matter. For example, if `guide/hello.md`'s content is defined as below, its final `id` is `guide/part1`. + +```yml +--- +id: part1 +--- +Lorem ipsum +``` + +If you want more control over the last part of the document URL, it is possible to add a `slug` (defaults to the `id`). + +```yml +--- +id: part1 +slug: part1.html +--- +Lorem ipsum +``` + +:::note + +It is possible to use: + +- absolute slugs: `slug: /mySlug`, `slug: /`... +- relative slugs: `slug: mySlug`, `slug: ./../mySlug`... + +::: + +## Home page docs + +If you want a document to be available at the root, and have a path like `https://v2.docusaurus.io/docs/`, you can use the slug frontmatter: + +```yml +--- +id: my-home-doc +slug: / +--- +Lorem ipsum +``` + +## Sidebar + +To generate a sidebar to your Docusaurus site, you need to define a file that exports a sidebar object and pass that into the `@docusaurus/plugin-docs` plugin directly or via `@docusaurus/preset-classic`. + +```js {8-9} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + // Sidebars filepath relative to the site dir. + sidebarPath: require.resolve('./sidebars.js'), + }, + // ... + }, + ], + ], +}; +``` + +### Sidebar object + +A sidebar object is defined like this: + +```typescript +type Sidebar = { + [sidebarId: string]: + | { + [sidebarCategory: string]: SidebarItem[]; + } + | SidebarItem[]; +}; +``` + +Below is an example of a sidebar object. The key `docs` is the id of the sidebar (can be renamed to something else) and `Getting Started` is a category within the sidebar. `greeting` and `doc1` are both [sidebar item](#sidebar-item). + +```js title="sidebars.js" +module.exports = { + docs: { + 'Getting started': ['greeting'], + Docusaurus: ['doc1'], + }, +}; +``` + +Keep in mind that EcmaScript does not guarantee `Object.keys({a,b}) === ['a','b']` (yet, this is generally true). If you don't want to rely on iteration order of JavaScript object keys for the category name, the following sidebar object is also equivalent of the above shorthand syntax. + +```js title="sidebars.js" +module.exports = { + docs: [ + { + type: 'category', + label: 'Getting Started', + items: ['greeting'], + }, + { + type: 'category', + label: 'Docusaurus', + items: ['doc1'], + }, + ], +}; +``` + +You can also have multiple sidebars for different Markdown files by adding more top-level keys to the exported object. + +Example: + +```js title="sidebars.js" +module.exports = { + firstSidebar: { + 'Category A': ['doc1'], + }, + secondSidebar: { + 'Category A': ['doc2'], + 'Category B': ['doc3'], + }, +}; +``` + +#### Sidebar item + +As the name implies, `SidebarItem` is an item defined in a Sidebar. There are a few types we support: + +- [Doc](#doc) +- [Link](#link) +- [Ref](#ref) +- [Category](#category) + +#### Doc + +```typescript +type SidebarItemDoc = + | string + | { + type: 'doc'; + id: string; + }; +``` + +Sidebar item type that links to a doc page. Example: + +```js +{ + type: 'doc', + id: 'doc1', // string - document id +} +``` + +Using just the [Document ID](#document-id) is perfectly valid as well, the following is equivalent to the above: + +```js +'doc1'; // string - document id +``` + +Note that using this type will bind the linked doc to current sidebar, this means that if you access `doc1` page, the sidebar displayed will be the sidebar this item is on. For below case, `doc1` is bounded to `firstSidebar`. + +```js title="sidebars.js" +module.exports = { + firstSidebar: { + 'Category A': ['doc1'], + }, + secondSidebar: { + 'Category A': ['doc2'], + 'Category B': ['doc3'], + }, +}; +``` + +#### Link + +```typescript +type SidebarItemLink = { + type: 'link'; + label: string; + href: string; +}; +``` + +Sidebar item type that links to a non-document page. Example: + +```js +{ + type: 'link', + label: 'Custom Label', // The label that should be displayed (string). + href: 'https://example.com' // The target URL (string). +} +``` + +#### Ref + +```typescript +type SidebarItemRef = { + type: 'ref'; + id: string; +}; +``` + +Sidebar item type that links to doc without bounding it to the sidebar. Example: + +```js +{ + type: 'ref', + id: 'doc1', // Document id (string). +} +``` + +#### Category + +This is used to add hierarchies to the sidebar: + +```typescript +type SidebarItemCategory = { + type: 'category'; + label: string; // Sidebar label text. + items: SidebarItem[]; // Array of sidebar items. + collapsed: boolean; // Set the category to be collapsed or open by default +}; +``` + +As an example, here's how we created the subcategory for "Docs" under "Guides" in this site: + +```js title="sidebars.js" +module.exports = { + docs: { + Guides: [ + 'creating-pages', + { + type: 'category', + label: 'Docs', + items: ['markdown-features', 'sidebar', 'versioning'], + }, + ], + }, +}; +``` + +**Note**: it's possible to use the shorthand syntax to create nested categories: + +```js title="sidebars.js" +module.exports = { + docs: { + Guides: [ + 'creating-pages', + { + Docs: ['markdown-features', 'sidebar', 'versioning'], + }, + ], + }, +}; +``` + +#### Collapsible categories + +For sites with a sizable amount of content, we support the option to expand/collapse a category to toggle the display of its contents. Categories are collapsible by default. If you want them to be always expanded, set `themeConfig.sidebarCollapsible` to `false`: + +```js {4} title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + sidebarCollapsible: false, + // ... + }, +}; +``` + +#### Expanded categories by default + +For docs that have collapsible categories, you may want more fine-grain control over certain categories. If you want specific categories to be always expanded, you can set `collapsed` to `false`: + +```js title="sidebars.js" +module.exports = { + docs: { + Guides: [ + 'creating-pages', + { + type: 'category', + label: 'Docs', + collapsed: false, + items: ['markdown-features', 'sidebar', 'versioning'], + }, + ], + }, +}; +``` + +## Docs-only mode + +If you only want the documentation feature, you can run your Docusaurus 2 site without a landing page and display your documentation page as the index page instead. + +To enable docs-only mode, set the docs plugin `routeBasePath: '/'`, and use the frontmatter `slug: /` on the document that should be the index page ([more infos](#home-page-docs)). + +:::caution + +You should delete the existing homepage at `./src/pages/index.js`, or else there will be two files mapping to the same route! + +::: + +:::tip + +There's also a "blog-only mode" for those who only want to use the blog feature of Docusaurus 2. You can use the same method detailed above. Follow the setup instructions on [Blog-only mode](blog.md#blog-only-mode). + +::: diff --git a/website/versioned_docs/version-2.0.0-alpha.66/docusaurus-core.md b/website/versioned_docs/version-2.0.0-alpha.66/docusaurus-core.md new file mode 100644 index 000000000000..f16164f56352 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/docusaurus-core.md @@ -0,0 +1,334 @@ +--- +id: docusaurus-core +title: Docusaurus Client API +sidebar_label: Client API +--- + +Docusaurus provides some APIs on the clients that can be helpful to you when building your site. + +## Components + +### `<Head/>` + +This reusable React component will manage all of your changes to the document head. It takes plain HTML tags and outputs plain HTML tags and is beginner-friendly. It is a wrapper around [React Helmet](https://github.com/nfl/react-helmet). + +Usage Example: + +```jsx {2,6,11} +import React from 'react'; +import Head from '@docusaurus/Head'; + +const MySEO = () => ( + <> + <Head> + <meta property="og:description" content="My custom description" /> + <meta charSet="utf-8" /> + <title>My Title + + + +); +``` + +Nested or latter components will override duplicate usages: + +```jsx {2,5,8,11} + + + My Title + + + + + + Nested Title + + + + +``` + +Outputs + +```html + + Nested Title + + +``` + +### `` + +This component enables linking to internal pages as well as a powerful performance feature called preloading. Preloading is used to prefetch resources so that the resources are fetched by the time the user navigates with this component. We use an `IntersectionObserver` to fetch a low-priority request when the `` is in the viewport and then use an `onMouseOver` event to trigger a high-priority request when it is likely that a user will navigate to the requested resource. + +The component is a wrapper around react-router’s `` component that adds useful enhancements specific to Docusaurus. All props are passed through to react-router’s `` component. + +```jsx {2,7} +import React from 'react'; +import Link from '@docusaurus/Link'; + +const Page = () => ( +
+

+ Check out my blog! +

+

+ {/* Note that external links still use `a` tags, but automatically opens in new tab. */} + Follow me on Twitter! +

+
+); +``` + +#### `to`: string + +The target location to navigate to. Example: `/docs/introduction`. + +```jsx + +``` + +### `` + +Rendering a `` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. You can refer to [React Router's Redirect documentation](https://reacttraining.com/react-router/web/api/Redirect) for more info on available props. + +Example usage: + +```jsx {2,5} +import React from 'react'; +import {Redirect} from '@docusaurus/router'; + +function Home() { + return ; +} +``` + +:::note + +`@docusaurus/router` implements [React Router](https://reacttraining.com/react-router/web/guides/quick-start) and supports its features. + +::: + +### `` + +The `` component accepts a `children` prop, a render function which will not be executed during the pre-rendering phase of the build process. This is useful for hiding code that is only meant to run in the browsers (e.g. where the `window`/`document` objects are being accessed). To improve SEO, you can also provide fallback content using the `fallback` prop, which will be prerendered until in the build process and replaced with the client-side only contents when viewed in the browser. + +```jsx +import BrowserOnly from '@docusaurus/BrowserOnly'; + +function MyComponent() { + return ( + The fallback content to display on prerendering}> + {() => { + // Something that should be excluded during build process prerendering. + }} + + ); +} +``` + +## Hooks + +### `useDocusaurusContext` + +React hook to access Docusaurus Context. Context contains `siteConfig` object from [docusaurus.config.js](api/docusaurus.config.js.md), and some additional site metadata. + +```ts +type DocusaurusPluginVersionInformation = + | {readonly type: 'package'; readonly version?: string} + | {readonly type: 'project'} + | {readonly type: 'local'} + | {readonly type: 'synthetic'}; + +interface DocusaurusSiteMetadata { + readonly docusaurusVersion: string; + readonly siteVersion?: string; + readonly pluginVersions: Record; +} + +interface DocusaurusContext { + siteConfig: DocusaurusConfig; + siteMetadata: DocusaurusSiteMetadata; +} +``` + +Usage example: + +```jsx {5,8,9} +import React from 'react'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; + +const MyComponent = () => { + const {siteConfig, siteMetadata} = useDocusaurusContext(); + return ( +
+

{siteConfig.title}

+
{siteMetadata.siteVersion}
+
{siteMetadata.docusaurusVersion}
+
+ ); +}; +``` + +### `useBaseUrl` + +React hook to automatically prepend `baseUrl` to a string automatically. This is particularly useful if you don't want to hardcode your config's `baseUrl`. We highly recommend you to use this. + +```ts +type BaseUrlOptions = { + forcePrependBaseUrl: boolean; + absolute: boolean; +}; +``` + +Example usage: + +```jsx {3,11} +import React from 'react'; +import Link from '@docusaurus/Link'; +import useBaseUrl from '@docusaurus/useBaseUrl'; + +function Help() { + return ( +
+

Browse the docs

+

+ Learn more about Docusaurus using the{' '} + official documentation +

+
+ ); +} +``` + +### `useBaseUrlUtils` + +Sometimes `useBaseUrl` is not good enough. This hook return additional utils related to your site's base url. + +- `withBaseUrl`: useful if you need to add base urls to multiple urls at once + +```jsx {2,5,6,7} +import React from 'react'; +import {useBaseUrlUtils} from '@docusaurus/useBaseUrl'; + +function Component() { + const urls = ['/a', '/b']; + const {withBaseUrl} = useBaseUrlUtils(); + const urlsWithBaseUrl = urls.map(withBaseUrl); + return
{/* ... */}
; +} +``` + +### `useGlobalData()` + +React hook to access Docusaurus global data created by all the plugins. + +Global data is namespaced by plugin name, and plugin id. + +:::info + +Plugin id is only useful when a plugin is used multiple times on the same site. Each plugin instance is able to create its own global data. + +::: + +```ts +type GlobalData = Record< + PluginName, + Record< + PluginId, // "default" by default + any // plugin-specific data + > +>; +``` + +Usage example: + +```jsx {2,5,6,7} +import React from 'react'; +import useGlobalData from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const globalData = useDocusaurusContext(); + const myPluginData = globalData['my-plugin']['default']; + return
{myPluginData.someAttribute}
; +}; +``` + +:::tip + +Inspect your site's global data at `./docusaurus/globalData.json` + +::: + +### `usePluginData(pluginName: string, pluginId?: string)` + +Access global data created by a specific plugin instance. + +This is the most convenient hook to access plugin global data, and should be used most of the time. + +`pluginId` is optional if you don't use multi-instance plugins. + +Usage example: + +```jsx {2,5,6} +import React from 'react'; +import {usePluginData} from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const myPluginData = usePluginData('my-plugin'); + return
{myPluginData.someAttribute}
; +}; +``` + +### `useAllPluginInstancesData(pluginName: string)` + +Access global data created by a specific plugin. Given a plugin name, it returns the data of all the plugins instances of that name, by plugin id. + +Usage example: + +```jsx {2,5,6,7} +import React from 'react'; +import {useAllPluginInstancesData} from '@docusaurus/useGlobalData'; + +const MyComponent = () => { + const allPluginInstancesData = useAllPluginInstancesData('my-plugin'); + const myPluginData = allPluginInstancesData['default']; + return
{myPluginData.someAttribute}
; +}; +``` + +## Modules + +### `ExecutionEnvironment` + +A module which exposes a few boolean variables to check the current rendering environment. Useful if you want to only run certain code on client/server or need to write server-side rendering compatible code. + +```jsx {2} +import React from 'react'; +import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; + +function MyPage() { + const location = ExecutionEnvironment.canUseDOM ? window.location.href : null; + return
{location}
; +} +``` + +| Field | Description | +| --- | --- | +| `ExecutionEnvironment.canUseDOM` | `true` if on client, `false` if prerendering. | +| `ExecutionEnvironment.canUseEventListeners` | `true` if on client and has `window.addEventListener`. | +| `ExecutionEnvironment.canUseIntersectionObserver` | `true` if on client and has `IntersectionObserver`. | +| `ExecutionEnvironment.canUseViewport` | `true` if on client and has `window.screen`. | + +### `constants` + +A module exposing useful constants to client-side theme code. + +```jsx +import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants'; +``` + +| Named export | Value | +| ------------------- | --------- | +| `DEFAULT_PLUGIN_ID` | `default` | diff --git a/website/versioned_docs/version-2.0.0-alpha.66/guides/creating-pages.md b/website/versioned_docs/version-2.0.0-alpha.66/guides/creating-pages.md new file mode 100644 index 000000000000..d90215dfc5c0 --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/guides/creating-pages.md @@ -0,0 +1,122 @@ +--- +id: creating-pages +title: Creating Pages +slug: /creating-pages +--- + +In this section, we will learn about creating ad-hoc pages in Docusaurus using React. This is most useful for creating one-off standalone pages like a showcase page, playground page or support page. + +The functionality of pages is powered by `@docusaurus/plugin-content-pages`. + +You can use React components, or Markdown. + +## Add a React page + +Create a file `/src/pages/helloReact.js`: + +```jsx title="/src/pages/helloReact.js" +import React from 'react'; +import Layout from '@theme/Layout'; + +function Hello() { + return ( + +
+

+ Edit pages/hello.js and save to reload. +

+
+
+ ); +} + +export default Hello; +``` + +Once you save the file, the development server will automatically reload the changes. Now open `http://localhost:3000/helloReact`, you will see the new page you just created. + +Each page doesn't come with any styling. You will need to import the `Layout` component from `@theme/Layout` and wrap your contents within that component if you want the navbar and/or footer to appear. + +:::tip + +You can also create TypeScript pages with the `.tsx` extension (`helloReact.tsx`). + +::: + +## Add a Markdown page + +Create a file `/src/pages/helloMarkdown.md`: + +```mdx title="/src/pages/helloMarkdown.md" +--- +title: my hello page title +description: my hello page description +hide_table_of_contents: true +--- + +# Hello + +How are you? +``` + +In the same way, a page will be created at `http://localhost:3000/helloMarkdown`. + +Markdown pages are less flexible than React pages, because it always uses the theme layout. + +Here's an [example Markdown page](/examples/markdownPageExample). + +:::tip + +You can use the full power of React in Markdown pages too, refer to the [MDX](https://mdxjs.com/) documentation. + +::: + +## Routing + +If you are familiar with other static site generators like Jekyll and Next, this routing approach will feel familiar to you. Any JavaScript file you create under `/src/pages/` directory will be automatically converted to a website page, following the `/src/pages/` directory hierarchy. For example: + +- `/src/pages/index.js` → `` +- `/src/pages/foo.js` → `/foo` +- `/src/pages/foo/test.js` → `/foo/test` +- `/src/pages/foo/index.js` → `/foo/` + +In this component-based development era, it is encouraged to co-locate your styling, markup and behavior together into components. Each page is a component, and if you need to customize your page design with your own styles, we recommend co-locating your styles with the page component in its own directory. For example, to create a "Support" page, you could do one of the following: + +- Add a `/src/pages/support.js` file +- Create a `/src/pages/support/` directory and a `/src/pages/support/index.js` file. + +The latter is preferred as it has the benefits of letting you put files related to the page within that directory. For example, a CSS module file (`styles.module.css`) with styles meant to only be used on the "Support" page. **Note:** this is merely a recommended directory structure and you will still need to manually import the CSS module file within your component module (`support/index.js`). By default, any Markdown or Javascript file starting with `_` will be ignored, and no routes will be created for that file (see the `exclude` option). + +```sh +my-website +├── src +│ └── pages +│ ├── styles.module.css +│ ├── index.js +| ├──_ignored.js +│ └── support +│ ├── index.js +│ └── styles.module.css +. +``` + +:::caution + +All JavaScript/TypeScript files within the `src/pages/` directory will have corresponding website paths generated for them. If you want to create reusable components into that directory, use the `exclude` option (by default, files prefixed with `_`, test files(`.test.js`) and files in `__tests__` directory are not turned into pages). + +::: + +## Using React + +React is used as the UI library to create pages. Every page component should export a React component, and you can leverage on the expressiveness of React to build rich and interactive content. + +## Duplicate Routes + +You may accidentally create multiple pages that are meant to be accessed on the same route. When this happens, Docusaurus will warn you about duplicate routes when you run `yarn start` or `yarn build`, but the site will still be built successfully. The page that was created last will be accessible, but it will override other conflicting pages. To resolve this issue, you should modify or remove any conflicting routes. diff --git a/website/versioned_docs/version-2.0.0-alpha.66/guides/migrating-from-v1-to-v2.md b/website/versioned_docs/version-2.0.0-alpha.66/guides/migrating-from-v1-to-v2.md new file mode 100644 index 000000000000..5ade15cbb94e --- /dev/null +++ b/website/versioned_docs/version-2.0.0-alpha.66/guides/migrating-from-v1-to-v2.md @@ -0,0 +1,894 @@ +--- +id: migrating-from-v1-to-v2 +title: Migrating from v1 to v2 +slug: /migrating-from-v1-to-v2 +--- + +import ColorGenerator from '@site/src/components/ColorGenerator'; + +:::caution + +This migration guide is targeted at Docusaurus users without translation and/or versioning features. + +::: + +This doc guides you through migrating an existing Docusaurus 1 site to Docusaurus 2. + +Your Docusaurus 1 site should have the following structure: + +```sh +├── docs +└── website + ├── blog + ├── core + │ └── Footer.js + ├── package.json + ├── pages + ├── sidebars.json + ├── siteConfig.js + └── static +``` + +After the migration, your Docusaurus 2 site could look like: + +```sh +website +├── blog +├── docs +├── src +│ ├── components +│ ├── css +│ └── pages +├── static +├── package.json +├── sidebars.json +├── docusaurus.config.js +``` + +:::tip + +You can use the [migration command](#migration-command) to take care of some of the migration chores. + +::: + +## Project setup + +### `package.json` + +#### Scoped package names + +In Docusaurus 2, we use scoped package names: + +- `docusaurus` -> `@docusaurus/core` + +This provides a clear distinction between Docusaurus' official packages and community maintained packages. In another words, all Docusaurus' official packages are namespaced under `@docusaurus/`. + +Meanwhile, the default doc site functionalities provided by Docusaurus 1 are now provided by `@docusaurus/preset-classic`. Therefore, we need to add this dependency as well: + +```diff title="package.json" +{ + dependencies: { +- "docusaurus": "^1.x.x", ++ "@docusaurus/core": "^2.0.0-alpha.48", ++ "@docusaurus/preset-classic": "^2.0.0-alpha.48", + } +} +``` + +:::tip + +Please use the most recent Docusaurus 2 alpha version, which you can check out [here](https://www.npmjs.com/package/@docusaurus/core) (it's tagged `next`). + +::: + +#### CLI commands + +Meanwhile, CLI commands are renamed to `docusaurus ` (instead of `docusaurus-command`). + +The `"scripts"` section of your `package.json` should be updated as follows: + +```json {3-6} title="package.json" +{ + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy" + // ... + } +} +``` + +A typical Docusaurus 2 `package.json` may look like this: + +```json title="package.json" +{ + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy" + }, + "dependencies": { + "@docusaurus/core": "^2.0.0-alpha.40", + "@docusaurus/preset-classic": "^2.0.0-alpha.40", + "clsx": "^1.1.1", + "react": "^16.10.2", + "react-dom": "^16.10.2" + }, + "browserslist": { + "production": [">0.2%", "not dead", "not op_mini all"], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} +``` + +### Update references to the `build` directory + +In Docusaurus 1, all the build artifacts are located within `website/build/`. + +In Docusaurus 2, it is now moved to just `website/build`. Make sure that you update your deployment configuration to read the generated files from the correct `build` directory. + +If you are deploying to GitHub pages, make sure to run `yarn deploy` instead of `yarn publish-gh-pages` script. + +### `.gitignore` + +The `.gitignore` in your `website` should contain: + +```bash title=".gitignore" +# 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* +``` + +### `README` + +The D1 website may have an existing README file. You can modify it to reflect the D2 changes, or copy the default [Docusaurus v2 README](https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-init/templates/classic/README.md). + +## Site configurations + +### `docusaurus.config.js` + +Rename `siteConfig.js` to `docusaurus.config.js`. + +In Docusaurus 2, we split each functionality (blog, docs, pages) into plugins for modularity. Presets are bundles of plugins and for backward compatibility we built a `@docusaurus/preset-classic` preset which bundles most of the essential plugins present in Docusaurus 1. + +Add the following preset configuration to your `docusaurus.config.js`. + +```jsx title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + // Docs folder path relative to website dir. + path: '../docs', + // Sidebars file relative to website dir. + sidebarPath: require.resolve('./sidebars.json'), + }, + // ... + }, + ], + ], +}; +``` + +We recommend moving the `docs` folder into the `website` folder and that is also the default directory structure in v2. [Now](https://zeit.co/now) supports [Docusaurus project deployments out-of-the-box](https://github.com/zeit/now-examples/tree/master/docusaurus) if the `docs` directory is within the `website`. It is also generally better for the docs to be within the website so that the docs and the rest of the website code are co-located within one `website` directory. + +If you are migrating your Docusaurus v1 website, and there are pending documentation pull requests, you can temporarily keep the `/docs` folder to its original place, to avoid producing conflicts. + +Refer to migration guide below for each field in `siteConfig.js`. + +### Updated fields + +#### `baseUrl`, `tagline`, `title`, `url`, `favicon`, `organizationName`, `projectName`, `githubHost`, `scripts`, `stylesheets` + +No actions needed, these configuration fields were not modified. + +#### `colors` + +Deprecated. We wrote a custom CSS framework for Docusaurus 2 called [Infima](https://facebookincubator.github.io/infima/) which uses CSS variables for theming. The docs are not quite ready yet and we will update here when it is. To overwrite Infima's CSS variables, create your own CSS file (e.g. `./src/css/custom.css`) and import it globally by passing it as an option to `@docusaurus/preset-classic`: + +```js {7-9} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + theme: { + customCss: [require.resolve('./src/css/custom.css')], + }, + }, + ], + ], +}; +``` + +Infima uses 7 shades of each color. + +```css title="/src/css/custom.css" +/** + * You can override the default Infima variables here. + * Note: this is not a complete list of --ifm- variables. + */ +:root { + --ifm-color-primary: #25c2a0; + --ifm-color-primary-dark: rgb(33, 175, 144); + --ifm-color-primary-darker: rgb(31, 165, 136); + --ifm-color-primary-darkest: rgb(26, 136, 112); + --ifm-color-primary-light: rgb(70, 203, 174); + --ifm-color-primary-lighter: rgb(102, 212, 189); + --ifm-color-primary-lightest: rgb(146, 224, 208); +} +``` + +We recommend using [ColorBox](https://www.colorbox.io/) to find the different shades of colors for your chosen primary color. + +Alteratively, use the following tool to generate the different shades for your website and copy the variables into `src/css/custom.css`. + + + +#### `footerIcon`, `copyright`, `ogImage`, `twitterImage`, `docsSideNavCollapsible` + +Site meta info such as assets, SEO, copyright info are now handled by themes. To customize them, use the `themeConfig` field in your `docusaurus.config.js`: + +```jsx title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + footer: { + logo: { + alt: 'Facebook Open Source Logo', + src: 'https://docusaurus.io/img/oss_logo.png', + href: 'https://opensource.facebook.com/', + }, + copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, // You can also put own HTML here. + }, + image: 'img/docusaurus.png', + // Equivalent to `docsSideNavCollapsible`. + sidebarCollapsible: false, + // ... + }, +}; +``` + +#### `headerIcon`, `headerLinks` + +In Docusaurus 1, header icon and header links were root fields in `siteConfig`: + +```js title="siteConfig.js" +headerIcon: 'img/docusaurus.svg', +headerLinks: [ + { doc: "doc1", label: "Getting Started" }, + { page: "help", label: "Help" }, + { href: "https://github.com/", label: "GitHub" }, + { blog: true, label: "Blog" }, +], +``` + +Now, these two fields are both handled by the theme: + +```jsx {6-19} title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + navbar: { + title: 'Docusaurus', + logo: { + alt: 'Docusaurus Logo', + src: 'img/docusaurus.svg', + }, + items: [ + {to: 'docs/doc1', label: 'Getting Started', position: 'left'}, + {to: 'help', label: 'Help', position: 'left'}, + { + href: 'https://github.com/', + label: 'GitHub', + position: 'right', + }, + {to: 'blog', label: 'Blog', position: 'left'}, + ], + }, + // ... + }, +}; +``` + +#### `algolia` + +```jsx {4-8} title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + algolia: { + apiKey: '47ecd3b21be71c5822571b9f59e52544', + indexName: 'docusaurus-2', + algoliaOptions: { //... }, + }, + // ... + }, +}; +``` + +#### `blogSidebarCount` + +Deprecated. Pass it as a blog option to `@docusaurus/preset-classic` instead: + +```jsx {8} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + blog: { + postsPerPage: 10, + }, + // ... + }, + ], + ], +}; +``` + +#### `cname` + +Deprecated. Create a `CNAME` file in your `static` folder instead with your custom domain. Files in the `static` folder will be copied into the root of the `build` folder during execution of the build command. + +#### `customDocsPath`, `docsUrl`, `editUrl`, `enableUpdateBy`, `enableUpdateTime` + +**BREAKING**: `editUrl` should point to (website) Docusaurus project instead of `docs` directory. + +Deprecated. Pass it as an option to `@docusaurus/preset-classic` docs instead: + +```jsx {8-20} title="docusaurus.config.js" +module.exports = { + // ... + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + // Equivalent to `customDocsPath`. + path: 'docs', + // Equivalent to `editUrl` but should point to `website` dir instead of `website/docs`. + editUrl: 'https://github.com/facebook/docusaurus/edit/master/website', + // Equivalent to `docsUrl`. + routeBasePath: 'docs', + // Remark and Rehype plugins passed to MDX. Replaces `markdownOptions` and `markdownPlugins`. + remarkPlugins: [], + rehypePlugins: [], + // Equivalent to `enableUpdateBy`. + showLastUpdateAuthor: true, + // Equivalent to `enableUpdateTime`. + showLastUpdateTime: true, + }, + // ... + }, + ], + ], +}; +``` + +#### `gaTrackingId` + +```jsx {5} title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + googleAnalytics: { + trackingID: 'UA-141789564-1', + }, + // ... + }, +}; +``` + +#### `gaGtag` + +```jsx {5} title="docusaurus.config.js" +module.exports = { + // ... + themeConfig: { + gtag: { + trackingID: 'UA-141789564-1', + }, + // ... + }, +}; +``` + +### Removed fields + +The following fields are all deprecated, you may remove from your configuration file. + +- `blogSidebarTitle` +- `cleanUrl` - Clean URL is used by default now. +- `defaultVersionShown` - Versioning is not ported yet. You'd be unable to migration to Docusaurus 2 if you are using versioning. Stay tuned. +- `disableHeaderTitle` +- `disableTitleTagline` +- `docsSideNavCollapsible` is available at `themeConfig.sidebarCollapsible`, and this is turned on by default now. +- `facebookAppId` +- `facebookComments` +- `facebookPixelId` +- `fonts` +- `highlight` - We now use [Prism](https://prismjs.com/) instead of [highlight.js](https://highlightjs.org/). +- `markdownOptions` - We use MDX in v2 instead of Remarkable. Your markdown options have to be converted to Remark/Rehype plugins. +- `markdownPlugins` - We use MDX in v2 instead of Remarkable. Your markdown plugins have to be converted to Remark/Rehype plugins. +- `manifest` +- `onPageNav` - This is turned on by default now. +- `separateCss` - It can imported in the same manner as `custom.css` mentioned above. +- `scrollToTop` +- `scrollToTopOptions` +- `translationRecruitingLink` +- `twitter` +- `twitterUsername` +- `useEnglishUrl` +- `users` +- `usePrism` - We now use [Prism](https://prismjs.com/) instead of [highlight.js](https://highlightjs.org/) +- `wrapPagesHTML` + +We intend to implement many of the deprecated config fields as plugins in future. Help will be appreciated! + +## Urls + +In v1, all pages were available with or without the `.html` extension. + +For example, these 2 pages exist: + +- [https://docusaurus.io/docs/en/installation](https://docusaurus.io/docs/en/installation) +- [https://docusaurus.io/docs/en/installation.html](https://docusaurus.io/docs/en/installation.html) + +If [`cleanUrl`](https://docusaurus.io/docs/en/site-config#cleanurl-boolean) was: + +- `true`: links would target `/installation` +- `false`: links would target `/installation.html` + +In v2, by default, the canonical page is `/installation`, and not `/installation.html`. + +If you had `cleanUrl: false` in v1, it's possible that people published links to `/installation.html`. + +For SEO reasons, and avoiding breaking links, you should configure server-side redirect rules on your hosting provider. + +As an escape hatch, you could use [@docusaurus/plugin-client-redirects](./using-plugins.md#docusaurusplugin-client-redirects) to create client-side redirects from `/installation.html` to `/installation`. + +```js +module.exports = { + plugins: [ + [ + '@docusaurus/plugin-client-redirects', + { + fromExtensions: ['html'], + }, + ], + ], +}; +``` + +If you want to keep the `.html` extension as the canonical url of a page, docs can declare a `slug: installation.html` frontmatter. + +## Components + +### Sidebar + +In previous version, nested sidebar category is not allowed and sidebar category can only contain doc id. However, v2 allows infinite nested sidebar and we have many types of [Sidebar Item](docs.md#sidebar-item) other than document. + +You'll have to migrate your sidebar if it contains category type. Rename `subcategory` to `category` and `ids` to `items`. + +```diff title="sidebars.json" +{ +- type: 'subcategory', ++ type: 'category', + label: 'My Example Subcategory', ++ items: ['doc1'], +- ids: ['doc1'] +}, +``` + +### Footer + +`website/core/Footer.js` is no longer needed. If you want to modify the default footer provided by Docusaurus, [swizzle](using-themes.md#swizzling-theme-components) it: + +```bash npm2yarn +npm run swizzle @docusaurus/theme-classic Footer +``` + +This will copy the current `