From 70c201c24dcf3acc338704cd71c54b21bdc0b77e Mon Sep 17 00:00:00 2001
From: John Knox
Date: Thu, 21 May 2020 12:34:33 +0100
Subject: [PATCH 01/26] feat(v2): open external links in new tab by default
(#2780)
Docusaurus is already opinionated about doing this, for example the navbar and
footer do this already.
This changes the Link component to do the same. This includes links in markdown
in the form of `[label](url)`.
You can override this behaviour by passing the target: '_self' prop.
---
packages/docusaurus/src/client/exports/Link.tsx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/docusaurus/src/client/exports/Link.tsx b/packages/docusaurus/src/client/exports/Link.tsx
index 8d7fb6408c..7db5334d7a 100644
--- a/packages/docusaurus/src/client/exports/Link.tsx
+++ b/packages/docusaurus/src/client/exports/Link.tsx
@@ -84,7 +84,10 @@ function Link({isNavLink, ...props}: Props) {
return !targetLink || !isInternal || targetLink.startsWith('#') ? (
// eslint-disable-next-line jsx-a11y/anchor-has-content
-
+
) : (
Date: Fri, 22 May 2020 06:18:27 +0300
Subject: [PATCH 02/26] refactor(v2): make external links more secure (#2783)
---
packages/docusaurus/src/client/exports/Link.tsx | 3 ++-
website/docs/docusaurus-core.md | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/packages/docusaurus/src/client/exports/Link.tsx b/packages/docusaurus/src/client/exports/Link.tsx
index 7db5334d7a..4d35824895 100644
--- a/packages/docusaurus/src/client/exports/Link.tsx
+++ b/packages/docusaurus/src/client/exports/Link.tsx
@@ -85,8 +85,9 @@ function Link({isNavLink, ...props}: Props) {
return !targetLink || !isInternal || targetLink.startsWith('#') ? (
// eslint-disable-next-line jsx-a11y/anchor-has-content
) : (
(
Check out my blog!
- {/* Note that external links still use `a` tags. */}
+ {/* Note that external links still use `a` tags, but automatically opens in new tab. */}
Follow me on Twitter!
From e6cdeba603ad373f862a1ade3d4c881fe7c95adb Mon Sep 17 00:00:00 2001
From: Muhammad Ali
Date: Fri, 22 May 2020 08:26:29 +0500
Subject: [PATCH 03/26] docs(v2): add articles section to resources page
(#2781)
---
website/docs/resources.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/website/docs/resources.md b/website/docs/resources.md
index b2da82a2fe..6bda806368 100644
--- a/website/docs/resources.md
+++ b/website/docs/resources.md
@@ -9,6 +9,10 @@ A curated list of interesting Docusaurus community projects.
- [F8 2019: Using Docusaurus to Create Open Source Websites](https://www.youtube.com/watch?v=QcGJsf6mgZE)
+## Articles
+
+- [Live code editing in Docusaurus](https://dev.to/mrmuhammadali/live-code-editing-in-docusaurus-28k)
+
## Showcase
See the showcase.
From b6b108e5b115c926223ca937058b283d089b7d91 Mon Sep 17 00:00:00 2001
From: James McShane
Date: Thu, 21 May 2020 22:27:47 -0500
Subject: [PATCH 04/26] misc: update debug config for Docusaurus v2 in VS Code
(#2775)
Adding instructions that work to debug docusaurus locally
---
admin/testing-changes-on-Docusaurus-itself.md | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/admin/testing-changes-on-Docusaurus-itself.md b/admin/testing-changes-on-Docusaurus-itself.md
index a675521c05..56f5b40b2b 100644
--- a/admin/testing-changes-on-Docusaurus-itself.md
+++ b/admin/testing-changes-on-Docusaurus-itself.md
@@ -30,9 +30,8 @@ Use the following code in VSCode to enable breakpoints. Please ensure you have a
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/website",
- "runtimeExecutable": "npm",
- "runtimeArgs": ["run", "start-debug"],
- "port": 9229
+ "program": "${workspaceFolder}/website/node_modules/@docusaurus/core/bin/docusaurus.js",
+ "args": ["start"],
}
]
}
From 783e7e7663a0593ab17a7682dc2377e1ee017a3c Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Fri, 22 May 2020 06:28:53 +0300
Subject: [PATCH 05/26] fix(v2): do not show sidebar on reserved docs home page
(#2785)
---
packages/docusaurus-plugin-content-docs/src/index.ts | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts
index bf00372608..7899c72e9b 100644
--- a/packages/docusaurus-plugin-content-docs/src/index.ts
+++ b/packages/docusaurus-plugin-content-docs/src/index.ts
@@ -342,7 +342,7 @@ export default function pluginContentDocs(
const versionsRegex = new RegExp(versionsNames.join('|'), 'i');
const routes = await Promise.all(
- metadataItems.map(async (metadataItem, i) => {
+ metadataItems.map(async (metadataItem) => {
const isDocsHomePage =
metadataItem.id.replace(versionsRegex, '').replace(/^\//, '') ===
options.homePageId;
@@ -353,10 +353,6 @@ export default function pluginContentDocs(
? ''
: metadataItem.version!) ?? '';
- // To show the sidebar, get the sidebar key of available sibling item.
- metadataItem.sidebar = (
- metadataItems[i - 1] ?? metadataItems[i + 1]
- ).sidebar;
const docsBaseMetadata = createDocsBaseMetadata(
metadataItem.version!,
);
From a7925f28be863854fafaeea75d9d8ceab9cf5687 Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Thu, 21 May 2020 23:36:46 -0400
Subject: [PATCH 06/26] fix(v2): use `require.resolve` for all webpack presets
and plugins (#2788)
---
packages/docusaurus/src/webpack/utils.ts | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/packages/docusaurus/src/webpack/utils.ts b/packages/docusaurus/src/webpack/utils.ts
index 06169abd69..2fda739cf1 100644
--- a/packages/docusaurus/src/webpack/utils.ts
+++ b/packages/docusaurus/src/webpack/utils.ts
@@ -100,7 +100,7 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader {
presets: [
isServer
? [
- '@babel/env',
+ require.resolve('@babel/preset-env'),
{
targets: {
node: 'current',
@@ -108,7 +108,7 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader {
},
]
: [
- '@babel/env',
+ require.resolve('@babel/preset-env'),
{
useBuiltIns: 'usage',
loose: true,
@@ -119,14 +119,14 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader {
exclude: ['transform-typeof-symbol'],
},
],
- '@babel/react',
- '@babel/preset-typescript',
+ require.resolve('@babel/preset-react'),
+ require.resolve('@babel/preset-typescript'),
],
plugins: [
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
- '@babel/plugin-transform-runtime',
+ require.resolve('@babel/plugin-transform-runtime'),
{
corejs: false,
helpers: true,
@@ -143,7 +143,9 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader {
},
],
// Adds syntax support for import()
- isServer ? 'dynamic-import-node' : '@babel/syntax-dynamic-import',
+ isServer
+ ? require.resolve('babel-plugin-dynamic-import-node')
+ : require.resolve('@babel/plugin-syntax-dynamic-import'),
],
},
babelOptions,
From faf48e9b166e3e6e2ce90bd1349d526c7e53c890 Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Fri, 22 May 2020 05:04:40 -0400
Subject: [PATCH 07/26] fix(v2): Resolve plugins relative to siteDir (#2789)
---
packages/docusaurus/src/server/plugins/init.ts | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/packages/docusaurus/src/server/plugins/init.ts b/packages/docusaurus/src/server/plugins/init.ts
index 244483467e..de8d098fd8 100644
--- a/packages/docusaurus/src/server/plugins/init.ts
+++ b/packages/docusaurus/src/server/plugins/init.ts
@@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
+import Module from 'module';
import importFresh from 'import-fresh';
import {LoadContext, Plugin, PluginConfig} from '@docusaurus/types';
@@ -15,9 +16,16 @@ export function initPlugins({
pluginConfigs: PluginConfig[];
context: LoadContext;
}): Plugin[] {
+ // We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
+ // declares the dependency on these plugins.
+ // We need to fallback to createRequireFromPath since createRequire is only available in node v12.
+ // See: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
+ const createRequire = Module.createRequire || Module.createRequireFromPath;
+ const pluginRequire = createRequire(context.siteDir);
+
const plugins: Plugin[] = pluginConfigs
.map((pluginItem) => {
- let pluginModuleImport;
+ let pluginModuleImport: string | undefined;
let pluginOptions = {};
if (!pluginItem) {
@@ -37,7 +45,9 @@ export function initPlugins({
// The pluginModuleImport value is any valid
// module identifier - npm package or locally-resolved path.
- const pluginModule: any = importFresh(pluginModuleImport);
+ const pluginModule: any = importFresh(
+ pluginRequire.resolve(pluginModuleImport),
+ );
return (pluginModule.default || pluginModule)(context, pluginOptions);
})
.filter(Boolean);
From 926cbb818bf84ae832694340e77681f6549bed2e Mon Sep 17 00:00:00 2001
From: Piotr Baran
Date: Fri, 22 May 2020 12:57:48 +0200
Subject: [PATCH 08/26] docs(v2): change docs for markdown features (#2786)
* fix(v2): change docs for markdown features
* Update doc1.md
* Update doc1.md
* Update doc1.md
Co-authored-by: Yangshun Tay
---
.../templates/bootstrap/docs/doc1.md | 23 ++++++++++++-------
.../templates/classic/docs/doc1.md | 23 ++++++++++++-------
.../templates/facebook/docs/doc1.md | 21 +++++++++++------
3 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
index 92fa8fbe45..af57d2d78d 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
@@ -28,9 +28,11 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-Emphasis, aka italics, with _asterisks_ or _underscores_.
+
+Emphasis, aka italics, with *asterisks* or _underscores_.
-Strong emphasis, aka bold, with **asterisks** or **underscores**.
+
+Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -41,17 +43,22 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Lists
1. First ordered list item
-1. Another item ⋅⋅\* Unordered sub-list.
-1. Actual numbers don't matter, just that it's a number ⋅⋅1. Ordered sub-list
+1. Another item
+ - Unordered sub-list.
+1. Actual numbers don't matter, just that it's a number
+ 1. Ordered sub-list
1. And another item.
-⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
+ You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
+ To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-- Unordered list can use asterisks
+
+* Unordered list can use asterisks
+
* Or minuses
+
- Or pluses
@@ -102,7 +109,7 @@ alert(s);
```python
s = "Python syntax highlighting"
-print(s)
+print s
```
```
diff --git a/packages/docusaurus-init/templates/classic/docs/doc1.md b/packages/docusaurus-init/templates/classic/docs/doc1.md
index 92fa8fbe45..af57d2d78d 100644
--- a/packages/docusaurus-init/templates/classic/docs/doc1.md
+++ b/packages/docusaurus-init/templates/classic/docs/doc1.md
@@ -28,9 +28,11 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-Emphasis, aka italics, with _asterisks_ or _underscores_.
+
+Emphasis, aka italics, with *asterisks* or _underscores_.
-Strong emphasis, aka bold, with **asterisks** or **underscores**.
+
+Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -41,17 +43,22 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Lists
1. First ordered list item
-1. Another item ⋅⋅\* Unordered sub-list.
-1. Actual numbers don't matter, just that it's a number ⋅⋅1. Ordered sub-list
+1. Another item
+ - Unordered sub-list.
+1. Actual numbers don't matter, just that it's a number
+ 1. Ordered sub-list
1. And another item.
-⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
+ You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
+ To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-- Unordered list can use asterisks
+
+* Unordered list can use asterisks
+
* Or minuses
+
- Or pluses
@@ -102,7 +109,7 @@ alert(s);
```python
s = "Python syntax highlighting"
-print(s)
+print s
```
```
diff --git a/packages/docusaurus-init/templates/facebook/docs/doc1.md b/packages/docusaurus-init/templates/facebook/docs/doc1.md
index 98cce3215d..af57d2d78d 100644
--- a/packages/docusaurus-init/templates/facebook/docs/doc1.md
+++ b/packages/docusaurus-init/templates/facebook/docs/doc1.md
@@ -28,9 +28,11 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-Emphasis, aka italics, with _asterisks_ or _underscores_.
+
+Emphasis, aka italics, with *asterisks* or _underscores_.
-Strong emphasis, aka bold, with **asterisks** or **underscores**.
+
+Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -41,17 +43,22 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Lists
1. First ordered list item
-1. Another item ⋅⋅\* Unordered sub-list.
-1. Actual numbers don't matter, just that it's a number ⋅⋅1. Ordered sub-list
+1. Another item
+ - Unordered sub-list.
+1. Actual numbers don't matter, just that it's a number
+ 1. Ordered sub-list
1. And another item.
-⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
+ You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
+ To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-- Unordered list can use asterisks
+
+* Unordered list can use asterisks
+
* Or minuses
+
- Or pluses
From 20fbceb9f1883a0d23ba52e79a4517b92631f7fd Mon Sep 17 00:00:00 2001
From: Yangshun Tay
Date: Fri, 22 May 2020 19:18:29 +0800
Subject: [PATCH 09/26] docs(v2): fix markdown syntax examples in templates
---
.../docusaurus-init/templates/bootstrap/docs/doc1.md | 12 ++++--------
.../docusaurus-init/templates/classic/docs/doc1.md | 12 ++++--------
.../docusaurus-init/templates/facebook/docs/doc1.md | 12 ++++--------
3 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
index af57d2d78d..e886a419dd 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
@@ -49,18 +49,14 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
- You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-
- To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-
* Unordered list can use asterisks
-
-* Or minuses
+- Or minuses
-- Or pluses
+
++ Or pluses
---
@@ -109,7 +105,7 @@ alert(s);
```python
s = "Python syntax highlighting"
-print s
+print(s)
```
```
diff --git a/packages/docusaurus-init/templates/classic/docs/doc1.md b/packages/docusaurus-init/templates/classic/docs/doc1.md
index af57d2d78d..e886a419dd 100644
--- a/packages/docusaurus-init/templates/classic/docs/doc1.md
+++ b/packages/docusaurus-init/templates/classic/docs/doc1.md
@@ -49,18 +49,14 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
- You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-
- To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-
* Unordered list can use asterisks
-
-* Or minuses
+- Or minuses
-- Or pluses
+
++ Or pluses
---
@@ -109,7 +105,7 @@ alert(s);
```python
s = "Python syntax highlighting"
-print s
+print(s)
```
```
diff --git a/packages/docusaurus-init/templates/facebook/docs/doc1.md b/packages/docusaurus-init/templates/facebook/docs/doc1.md
index af57d2d78d..e886a419dd 100644
--- a/packages/docusaurus-init/templates/facebook/docs/doc1.md
+++ b/packages/docusaurus-init/templates/facebook/docs/doc1.md
@@ -49,18 +49,14 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
- You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-
- To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-
* Unordered list can use asterisks
-
-* Or minuses
+- Or minuses
-- Or pluses
+
++ Or pluses
---
@@ -109,7 +105,7 @@ alert(s);
```python
s = "Python syntax highlighting"
-print s
+print(s)
```
```
From 1503943e3f4cc2eb1f006f9d83f9b6bb539cb99f Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Fri, 22 May 2020 16:57:02 -0400
Subject: [PATCH 10/26] fix(v2): Use `require.resolve` to resolve plugin path
in presets (#2794)
---
.../docusaurus-preset-bootstrap/src/index.js | 8 ++++----
.../docusaurus-preset-classic/src/index.js | 18 ++++++++++--------
website/docs/presets.md | 7 +++++--
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/packages/docusaurus-preset-bootstrap/src/index.js b/packages/docusaurus-preset-bootstrap/src/index.js
index 7058e0e962..66f4363b66 100644
--- a/packages/docusaurus-preset-bootstrap/src/index.js
+++ b/packages/docusaurus-preset-bootstrap/src/index.js
@@ -7,11 +7,11 @@
module.exports = function preset(context, opts = {}) {
return {
- themes: [['@docusaurus/theme-bootstrap', opts.theme]],
+ themes: [[require.resolve('@docusaurus/theme-bootstrap'), opts.theme]],
plugins: [
- ['@docusaurus/plugin-content-pages', opts.pages],
- ['@docusaurus/plugin-content-blog', opts.blog],
- ['@docusaurus/plugin-content-docs', opts.docs],
+ [require.resolve('@docusaurus/plugin-content-pages'), opts.pages],
+ [require.resolve('@docusaurus/plugin-content-blog'), opts.blog],
+ [require.resolve('@docusaurus/plugin-content-docs'), opts.docs],
],
};
};
diff --git a/packages/docusaurus-preset-classic/src/index.js b/packages/docusaurus-preset-classic/src/index.js
index ac74ef9269..2a4d489bcc 100644
--- a/packages/docusaurus-preset-classic/src/index.js
+++ b/packages/docusaurus-preset-classic/src/index.js
@@ -13,17 +13,19 @@ module.exports = function preset(context, opts = {}) {
return {
themes: [
- ['@docusaurus/theme-classic', opts.theme],
+ [require.resolve('@docusaurus/theme-classic'), opts.theme],
// Don't add this if algolia config is not defined.
- algolia && '@docusaurus/theme-search-algolia',
+ algolia && require.resolve('@docusaurus/theme-search-algolia'),
],
plugins: [
- ['@docusaurus/plugin-content-docs', opts.docs],
- ['@docusaurus/plugin-content-blog', opts.blog],
- ['@docusaurus/plugin-content-pages', opts.pages],
- isProd && googleAnalytics && '@docusaurus/plugin-google-analytics',
- isProd && gtag && '@docusaurus/plugin-google-gtag',
- isProd && ['@docusaurus/plugin-sitemap', opts.sitemap],
+ [require.resolve('@docusaurus/plugin-content-docs'), opts.docs],
+ [require.resolve('@docusaurus/plugin-content-blog'), opts.blog],
+ [require.resolve('@docusaurus/plugin-content-pages'), opts.pages],
+ isProd &&
+ googleAnalytics &&
+ require.resolve('@docusaurus/plugin-google-analytics'),
+ isProd && gtag && require.resolve('@docusaurus/plugin-google-gtag'),
+ isProd && [require.resolve('@docusaurus/plugin-sitemap'), opts.sitemap],
],
};
};
diff --git a/website/docs/presets.md b/website/docs/presets.md
index 872be9dc31..44d07c8fb2 100644
--- a/website/docs/presets.md
+++ b/website/docs/presets.md
@@ -40,8 +40,11 @@ Presets in some way are a shorthand function to add plugins and themes to your d
```js
module.exports = function preset(context, opts = {}) {
return {
- themes: ['@docusaurus/themes-cool', '@docusaurus/themes-bootstrap'],
- plugins: ['@docusaurus/plugin-blog'],
+ themes: [
+ require.resolve('@docusaurus/themes-cool'),
+ require.resolve('@docusaurus/themes-bootstrap'),
+ ],
+ plugins: [require.resolve('@docusaurus/plugin-blog')],
};
};
```
From 85a694448f47a5dd86650d1ec9629a7339fbf846 Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Fri, 22 May 2020 16:58:21 -0400
Subject: [PATCH 11/26] fix(v2): Ensure that theme classic require webpack
provided by `@docusaurus/core` (#2795)
---
packages/docusaurus-theme-classic/src/index.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/packages/docusaurus-theme-classic/src/index.js b/packages/docusaurus-theme-classic/src/index.js
index 7cce15b4c5..54c997dcd7 100644
--- a/packages/docusaurus-theme-classic/src/index.js
+++ b/packages/docusaurus-theme-classic/src/index.js
@@ -6,7 +6,15 @@
*/
const path = require('path');
-const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
+const Module = require('module');
+
+const createRequire = Module.createRequire || Module.createRequireFromPath;
+const requireFromDocusaurusCore = createRequire(
+ require.resolve('@docusaurus/core/package.json'),
+);
+const ContextReplacementPlugin = requireFromDocusaurusCore(
+ 'webpack/lib/ContextReplacementPlugin',
+);
// Need to be inlined to prevent dark mode FOUC
// Make sure that the 'storageKey' is the same as the one in `/theme/hooks/useTheme.js`
From 83f980cadfd495b721c359320abea29aac371650 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sat, 23 May 2020 00:02:18 +0300
Subject: [PATCH 12/26] refactor(v2): show only search icon on mobiles (#2791)
---
.../src/theme/Navbar/styles.module.css | 2 +-
.../src/theme/SearchBar/index.js | 67 ++++++++++---------
.../src/theme/SearchBar/styles.css | 40 -----------
.../src/theme/SearchBar/styles.module.css | 62 +++++++++++++++++
4 files changed, 97 insertions(+), 74 deletions(-)
delete mode 100644 packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css
create mode 100644 packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/styles.module.css b/packages/docusaurus-theme-classic/src/theme/Navbar/styles.module.css
index 7d59c599a1..fb524ac417 100644
--- a/packages/docusaurus-theme-classic/src/theme/Navbar/styles.module.css
+++ b/packages/docusaurus-theme-classic/src/theme/Navbar/styles.module.css
@@ -11,7 +11,7 @@
}
}
-@media (max-width: 360px) {
+@media (max-width: 768px) {
.hideLogoText {
display: none;
}
diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
index 90abee0778..743ea73a74 100644
--- a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
+++ b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
@@ -12,9 +12,9 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import {useHistory} from '@docusaurus/router';
import useSearchQuery from '@theme/hooks/useSearchQuery';
-import './styles.css';
+import styles from './styles.module.css';
-const Search = (props) => {
+const Search = ({handleSearchBarToggle, isSearchBarExpanded}) => {
const [algoliaLoaded, setAlgoliaLoaded] = useState(false);
const searchBarRef = useRef(null);
const {siteConfig = {}} = useDocusaurusContext();
@@ -76,19 +76,19 @@ const Search = (props) => {
);
};
- const handleSearchIcon = useCallback(() => {
+ const toggleSearchInput = useCallback(() => {
loadAlgolia();
if (algoliaLoaded) {
searchBarRef.current.focus();
}
- props.handleSearchBarToggle(!props.isSearchBarExpanded);
- }, [props.isSearchBarExpanded]);
+ handleSearchBarToggle(!isSearchBarExpanded);
+ }, [isSearchBarExpanded]);
const handleSearchInputBlur = useCallback(() => {
- props.handleSearchBarToggle(!props.isSearchBarExpanded);
- }, [props.isSearchBarExpanded]);
+ handleSearchBarToggle(!isSearchBarExpanded);
+ }, [isSearchBarExpanded]);
const handleSearchInput = useCallback((e) => {
const needFocus = e.type !== 'mouseover';
@@ -104,32 +104,33 @@ const Search = (props) => {
return (
-
-
+
+
+
+
+
);
};
diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css
deleted file mode 100644
index f9053f5845..0000000000
--- a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.
- */
-
-.search-icon {
- background-image: var(--ifm-navbar-search-input-icon);
- height: auto;
- width: 24px;
- cursor: pointer;
- padding: 8px;
- line-height: 32px;
- background-repeat: no-repeat;
- background-position: center;
- display: none;
-}
-
-.search-icon-hidden {
- visibility: hidden;
-}
-
-@media (max-width: 360px) {
- .search-bar {
- width: 0 !important;
- background: none !important;
- padding: 0 !important;
- transition: none !important;
- }
-
- .search-bar-expanded {
- width: 9rem !important;
- }
-
- .search-icon {
- display: inline;
- vertical-align: sub;
- }
-}
diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
new file mode 100644
index 0000000000..780f618f77
--- /dev/null
+++ b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+.searchIconButton {
+ display: none;
+}
+
+@media (max-width: 768px) {
+ .searchIconButton {
+ display: block;
+ position: absolute;
+ right: 0;
+ width: 2.75rem;
+ height: 2rem;
+ z-index: 1;
+ }
+
+ .searchIconButtonHidden {
+ visibility: hidden;
+ }
+
+ :global(.navbar__items:first-of-type) {
+ flex: 0 1 auto;
+ }
+
+ :global(.navbar__inner) {
+ position: relative;
+ }
+
+ :global(.navbar__search) {
+ position: relative;
+ flex: 1 1 auto;
+ padding-left: 0;
+ }
+
+ .searchWrapper {
+ position: absolute;
+ top: calc(var(--ifm-navbar-padding-vertical) * 2 * -1);
+ width: 100%;
+ display: flex;
+ justify-content: flex-end;
+ }
+
+ .searchInput {
+ width: 0;
+ transition: width 0.3s ease-in-out;
+ }
+
+ .searchInputExpanded {
+ width: 100%;
+ }
+
+ :global(.algolia-autocomplete) {
+ width: 100%;
+ display: flex !important;
+ justify-content: flex-end;
+ }
+}
From 0ff6dd31f4ade91f8dc5cb55fdf3c3cb45819be5 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sat, 23 May 2020 00:05:16 +0300
Subject: [PATCH 13/26] style(v2): disable Prettier checks for Markdown files
of init templates (#2792)
---
.prettierignore | 1 +
packages/docusaurus-init/templates/bootstrap/docs/doc1.md | 5 -----
packages/docusaurus-init/templates/classic/docs/doc1.md | 5 -----
packages/docusaurus-init/templates/facebook/docs/doc1.md | 5 -----
4 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/.prettierignore b/.prettierignore
index e918d160e8..f54d393509 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -5,6 +5,7 @@ build
packages/docusaurus-utils/lib/
packages/docusaurus/lib/
packages/docusaurus-init/lib/
+packages/docusaurus-init/templates/**/*.md
packages/docusaurus-plugin-content-blog/lib/
packages/docusaurus-plugin-content-docs/lib/
packages/docusaurus-plugin-content-pages/lib/
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
index e886a419dd..448cb69a98 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
@@ -28,10 +28,8 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-
Emphasis, aka italics, with *asterisks* or _underscores_.
-
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -49,13 +47,10 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
-
* Unordered list can use asterisks
-
- Or minuses
-
+ Or pluses
---
diff --git a/packages/docusaurus-init/templates/classic/docs/doc1.md b/packages/docusaurus-init/templates/classic/docs/doc1.md
index e886a419dd..448cb69a98 100644
--- a/packages/docusaurus-init/templates/classic/docs/doc1.md
+++ b/packages/docusaurus-init/templates/classic/docs/doc1.md
@@ -28,10 +28,8 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-
Emphasis, aka italics, with *asterisks* or _underscores_.
-
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -49,13 +47,10 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
-
* Unordered list can use asterisks
-
- Or minuses
-
+ Or pluses
---
diff --git a/packages/docusaurus-init/templates/facebook/docs/doc1.md b/packages/docusaurus-init/templates/facebook/docs/doc1.md
index e886a419dd..448cb69a98 100644
--- a/packages/docusaurus-init/templates/facebook/docs/doc1.md
+++ b/packages/docusaurus-init/templates/facebook/docs/doc1.md
@@ -28,10 +28,8 @@ To serve as an example page when styling markdown based Docusaurus sites.
## Emphasis
-
Emphasis, aka italics, with *asterisks* or _underscores_.
-
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
@@ -49,13 +47,10 @@ Strikethrough uses two tildes. ~~Scratch this.~~
1. Ordered sub-list
1. And another item.
-
* Unordered list can use asterisks
-
- Or minuses
-
+ Or pluses
---
From 0e61da8f69cb8e59907233263079a7f5f34ab7c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kasper=20B=C3=B8gebjerg=20Pedersen?=
Date: Sat, 23 May 2020 00:07:01 +0200
Subject: [PATCH 14/26] feat(v2): allow specifying of remark and rehype plugins
before default plugins (#2689)
* feat(v2): swap order of markdown plugins
* feat(v2): remark/rehype plugins can override default plugins
---
packages/docusaurus-mdx-loader/src/index.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/packages/docusaurus-mdx-loader/src/index.js b/packages/docusaurus-mdx-loader/src/index.js
index d17854083f..851ff6cc0b 100644
--- a/packages/docusaurus-mdx-loader/src/index.js
+++ b/packages/docusaurus-mdx-loader/src/index.js
@@ -27,10 +27,12 @@ module.exports = async function (fileString) {
const options = {
...reqOptions,
remarkPlugins: [
+ ...(reqOptions.beforeDefaultRemarkPlugins || []),
...DEFAULT_OPTIONS.remarkPlugins,
...(reqOptions.remarkPlugins || []),
],
rehypePlugins: [
+ ...(reqOptions.beforeDefaultRehypePlugins || []),
...DEFAULT_OPTIONS.rehypePlugins,
...(reqOptions.rehypePlugins || []),
],
From 2dbd0488d72832e340fb711900abbe16cea61669 Mon Sep 17 00:00:00 2001
From: Yangshun Tay
Date: Sat, 23 May 2020 06:12:24 +0800
Subject: [PATCH 15/26] docs(v2): document beforeDefaultRemarkPlugins and
beforeDefaultRehypePlugins
---
website/docs/using-plugins.md | 40 +++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/website/docs/using-plugins.md b/website/docs/using-plugins.md
index d516309603..d0621b23d4 100644
--- a/website/docs/using-plugins.md
+++ b/website/docs/using-plugins.md
@@ -145,36 +145,42 @@ module.exports = {
'@docusaurus/plugin-content-blog',
{
/**
- * Path to data on filesystem
- * relative to site dir
+ * Path to data on filesystem relative to site dir.
*/
path: 'blog',
/**
- * URL for editing a blog post, example: 'https://github.com/facebook/docusaurus/edit/master/website/blog/'
+ * URL for editing a blog post.
+ * Example: 'https://github.com/facebook/docusaurus/edit/master/website/blog/'
*/
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/blog/',
/**
- * URL route for the blog section of your site
- * do not include trailing slash
+ * URL route for the blog section of your site.
+ * *DO NOT* include a trailing slash.
*/
routeBasePath: 'blog',
include: ['*.md', '*.mdx'],
postsPerPage: 10,
/**
- * Theme components used by the blog pages
+ * Theme components used by the blog pages.
*/
blogListComponent: '@theme/BlogListPage',
blogPostComponent: '@theme/BlogPostPage',
blogTagsListComponent: '@theme/BlogTagsListPage',
blogTagsPostsComponent: '@theme/BlogTagsPostsPage',
/**
- * Remark and Rehype plugins passed to MDX
+ * Remark and Rehype plugins passed to MDX.
*/
remarkPlugins: [
/* require('remark-math') */
],
rehypePlugins: [],
+ /**
+ * Custom Remark and Rehype plugins passed to MDX before
+ * the default Docusaurus Remark and Rehype plugins.
+ */
+ beforeDefaultRemarkPlugins: [],
+ beforeDefaultRehypePlugins: [],
/**
* Truncate marker, can be a regex or string.
*/
@@ -184,8 +190,8 @@ module.exports = {
*/
showReadingTime: true,
/**
- * Blog feed
- * If feedOptions is undefined, no rss feed will be generated
+ * Blog feed.
+ * If feedOptions is undefined, no rss feed will be generated.
*/
feedOptions: {
type: '', // required. 'rss' | 'feed' | 'all'
@@ -223,17 +229,17 @@ module.exports = {
'@docusaurus/plugin-content-docs',
{
/**
- * Path to data on filesystem
- * relative to site dir
+ * Path to data on filesystem relative to site dir.
*/
path: 'docs',
/**
- * URL for editing website repo, example: 'https://github.com/facebook/docusaurus/edit/master/website/'
+ * URL for editing a doc in the website repo.
+ * Example: 'https://github.com/facebook/docusaurus/edit/master/website/'
*/
editUrl: 'https://github.com/facebook/docusaurus/edit/master/website/',
/**
- * URL route for the blog section of your site
- * do not include trailing slash
+ * URL route for the blog section of your site.
+ * *DO NOT* include a trailing slash.
*/
routeBasePath: 'docs',
homePageId: '_index', // Document id for docs home page.
@@ -255,6 +261,12 @@ module.exports = {
/* require('remark-math') */
],
rehypePlugins: [],
+ /**
+ * Custom Remark and Rehype plugins passed to MDX before
+ * the default Docusaurus Remark and Rehype plugins.
+ */
+ beforeDefaultRemarkPlugins: [],
+ beforeDefaultRehypePlugins: [],
/**
* Whether to display the author who last updated the doc.
*/
From 78136e77a27bfdb678c104e720e1b2142d3dbe4b Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Fri, 22 May 2020 23:25:23 -0400
Subject: [PATCH 16/26] feat(v2): Use pnp-webpack-plugin to support pnp module
resolution (#2796)
---
packages/docusaurus/package.json | 1 +
packages/docusaurus/src/webpack/base.ts | 5 +++++
yarn.lock | 12 ++++++++++++
3 files changed, 18 insertions(+)
diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json
index fafa327e16..1744bb0c13 100644
--- a/packages/docusaurus/package.json
+++ b/packages/docusaurus/package.json
@@ -69,6 +69,7 @@
"nprogress": "^0.2.0",
"null-loader": "^3.0.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
+ "pnp-webpack-plugin": "^1.6.4",
"portfinder": "^1.0.25",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts
index e413d873c8..6526b50111 100644
--- a/packages/docusaurus/src/webpack/base.ts
+++ b/packages/docusaurus/src/webpack/base.ts
@@ -8,6 +8,7 @@
import fs from 'fs-extra';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
+import PnpWebpackPlugin from 'pnp-webpack-plugin';
import path from 'path';
import TerserPlugin from 'terser-webpack-plugin';
import {Configuration, Loader} from 'webpack';
@@ -74,6 +75,10 @@ export function createBaseConfig(
'node_modules',
path.resolve(fs.realpathSync(process.cwd()), 'node_modules'),
],
+ plugins: [PnpWebpackPlugin],
+ },
+ resolveLoader: {
+ plugins: [PnpWebpackPlugin.moduleLoader(module)],
},
optimization: {
removeAvailableModules: false,
diff --git a/yarn.lock b/yarn.lock
index e9d21b70b2..4d677ae62b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -13023,6 +13023,13 @@ pngjs@^3.0.0, pngjs@^3.3.3:
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f"
integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==
+pnp-webpack-plugin@^1.6.4:
+ version "1.6.4"
+ resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.6.4.tgz#c9711ac4dc48a685dabafc86f8b6dd9f8df84149"
+ integrity sha512-7Wjy+9E3WwLOEL30D+m8TSTF7qJJUJLONBnwQp0518siuMxUQUbgZwssaFX+QKlZkjHZcw/IpZCt/H0srrntSg==
+ dependencies:
+ ts-pnp "^1.1.6"
+
popper.js@^1.14.4:
version "1.16.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
@@ -16936,6 +16943,11 @@ tryer@^1.0.1:
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
+ts-pnp@^1.1.6:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
+ integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==
+
tslib@^1.10.0, tslib@^1.9.0:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
From 705f8f3c51c977216e7a76209d9d5997075de2d6 Mon Sep 17 00:00:00 2001
From: Sam Zhou
Date: Fri, 22 May 2020 23:26:50 -0400
Subject: [PATCH 17/26] fix(v2): Consistently use require.resolve in official
plugins to resolve modules (#2797)
* fix(v2): Use require.resolve to resolve loaders in official plugins
* Use require.resolve to resolve client modules
---
packages/docusaurus-plugin-content-blog/src/index.ts | 4 ++--
packages/docusaurus-plugin-content-docs/src/index.ts | 4 ++--
packages/docusaurus-plugin-ideal-image/src/index.ts | 4 ++--
packages/docusaurus-theme-bootstrap/src/index.js | 2 +-
packages/docusaurus-theme-classic/src/index.js | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts
index eda67a9628..17d8c0de1e 100644
--- a/packages/docusaurus-plugin-content-blog/src/index.ts
+++ b/packages/docusaurus-plugin-content-blog/src/index.ts
@@ -102,7 +102,7 @@ export default function pluginContentBlog(
const modules = [];
if (options.admonitions) {
- modules.push('remark-admonitions/styles/infima.css');
+ modules.push(require.resolve('remark-admonitions/styles/infima.css'));
}
return modules;
@@ -396,7 +396,7 @@ export default function pluginContentBlog(
getCacheLoader(isServer),
getBabelLoader(isServer),
{
- loader: '@docusaurus/mdx-loader',
+ loader: require.resolve('@docusaurus/mdx-loader'),
options: {
remarkPlugins,
rehypePlugins,
diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts
index 7899c72e9b..19405bd07d 100644
--- a/packages/docusaurus-plugin-content-docs/src/index.ts
+++ b/packages/docusaurus-plugin-content-docs/src/index.ts
@@ -142,7 +142,7 @@ export default function pluginContentDocs(
const modules = [];
if (options.admonitions) {
- modules.push('remark-admonitions/styles/infima.css');
+ modules.push(require.resolve('remark-admonitions/styles/infima.css'));
}
return modules;
@@ -522,7 +522,7 @@ export default function pluginContentDocs(
getCacheLoader(isServer),
getBabelLoader(isServer),
{
- loader: '@docusaurus/mdx-loader',
+ loader: require.resolve('@docusaurus/mdx-loader'),
options: {
remarkPlugins,
rehypePlugins,
diff --git a/packages/docusaurus-plugin-ideal-image/src/index.ts b/packages/docusaurus-plugin-ideal-image/src/index.ts
index ecc5ecba23..2cec59ac00 100644
--- a/packages/docusaurus-plugin-ideal-image/src/index.ts
+++ b/packages/docusaurus-plugin-ideal-image/src/index.ts
@@ -27,9 +27,9 @@ export default function (_context: LoadContext, options: PluginOptions) {
{
test: /\.(png|jpe?g|gif)$/i,
use: [
- '@docusaurus/lqip-loader',
+ require.resolve('@docusaurus/lqip-loader'),
{
- loader: '@endiliey/responsive-loader',
+ loader: require.resolve('@endiliey/responsive-loader'),
options: {
emitFile: !isServer, // don't emit for server-side rendering
disable: !isProd,
diff --git a/packages/docusaurus-theme-bootstrap/src/index.js b/packages/docusaurus-theme-bootstrap/src/index.js
index 81e9229420..65125a85b2 100644
--- a/packages/docusaurus-theme-bootstrap/src/index.js
+++ b/packages/docusaurus-theme-bootstrap/src/index.js
@@ -14,7 +14,7 @@ module.exports = function () {
return path.resolve(__dirname, './theme');
},
getClientModules() {
- return ['bootstrap/dist/css/bootstrap.min.css'];
+ return [require.resolve('bootstrap/dist/css/bootstrap.min.css')];
},
};
};
diff --git a/packages/docusaurus-theme-classic/src/index.js b/packages/docusaurus-theme-classic/src/index.js
index 54c997dcd7..cbe3e4c914 100644
--- a/packages/docusaurus-theme-classic/src/index.js
+++ b/packages/docusaurus-theme-classic/src/index.js
@@ -65,7 +65,7 @@ module.exports = function (context, options) {
getClientModules() {
const modules = [
- 'infima/dist/css/default/default.css',
+ require.resolve('infima/dist/css/default/default.css'),
path.resolve(__dirname, './prism-include-languages'),
];
From a7e4013d3ba6497a4310d74cd2cf3bd3e1a2e154 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sat, 23 May 2020 11:23:28 +0300
Subject: [PATCH 18/26] chore: prettier
---
admin/testing-changes-on-Docusaurus-itself.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/admin/testing-changes-on-Docusaurus-itself.md b/admin/testing-changes-on-Docusaurus-itself.md
index 56f5b40b2b..8624bb38f8 100644
--- a/admin/testing-changes-on-Docusaurus-itself.md
+++ b/admin/testing-changes-on-Docusaurus-itself.md
@@ -31,7 +31,7 @@ Use the following code in VSCode to enable breakpoints. Please ensure you have a
"request": "launch",
"cwd": "${workspaceFolder}/website",
"program": "${workspaceFolder}/website/node_modules/@docusaurus/core/bin/docusaurus.js",
- "args": ["start"],
+ "args": ["start"]
}
]
}
From 604f9f5b25fa4355099726f5a31054c8f0f75a6f Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sun, 24 May 2020 07:45:38 +0300
Subject: [PATCH 19/26] refactor(v2): increase search input on medium screens
(#2799)
* refactor(v2): show only search icon on mobiles
* refactor(v2): increase search input on medium screens
---
.../src/theme/SearchBar/index.js | 1 +
.../src/theme/SearchBar/styles.module.css | 19 +++++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
index 743ea73a74..d2b64f98a8 100644
--- a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
+++ b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
@@ -35,6 +35,7 @@ const Search = ({handleSearchBarToggle, isSearchBarExpanded}) => {
openOnFocus: true,
autoselect: false,
hint: false,
+ tabAutocomplete: false,
},
// Override algolia's default selection event, allowing us to do client-side
// navigation and avoiding a full page refresh.
diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
index 780f618f77..cbfb5347e8 100644
--- a/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
+++ b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.module.css
@@ -9,6 +9,13 @@
display: none;
}
+@media (min-width: 769px) and (max-width: 996px) {
+ :global(.navbar__search),
+ :global(.navbar__search-input) {
+ width: 100%;
+ }
+}
+
@media (max-width: 768px) {
.searchIconButton {
display: block;
@@ -53,10 +60,10 @@
.searchInputExpanded {
width: 100%;
}
-
- :global(.algolia-autocomplete) {
- width: 100%;
- display: flex !important;
- justify-content: flex-end;
- }
+}
+
+:global(.algolia-autocomplete) {
+ width: 100%;
+ display: flex !important;
+ justify-content: flex-end;
}
From 2e12269f94d7d9461a1d2c4e4174ca4019bf2dfc Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sun, 24 May 2020 07:48:04 +0300
Subject: [PATCH 20/26] misc: use branded favicon in init templates (#2803)
---
.../templates/bootstrap/static/img/favicon.ico | Bin 766 -> 3626 bytes
.../templates/classic/static/img/favicon.ico | Bin 766 -> 3626 bytes
.../templates/facebook/static/img/favicon.ico | Bin 766 -> 3626 bytes
3 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/packages/docusaurus-init/templates/bootstrap/static/img/favicon.ico b/packages/docusaurus-init/templates/bootstrap/static/img/favicon.ico
index be74abd69ad6a32de7375df13cab9354798e328f..c01d54bcd39a5f853428f3cd5aa0f383d963c484 100644
GIT binary patch
literal 3626
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
Date: Sun, 24 May 2020 00:48:36 -0400
Subject: [PATCH 21/26] fix(v2): Properly declare peerDependencies (#2806)
---
packages/docusaurus-preset-bootstrap/package.json | 4 +++-
packages/docusaurus-preset-classic/package.json | 4 +++-
packages/docusaurus-theme-bootstrap/package.json | 3 +--
packages/docusaurus-theme-classic/package.json | 4 ++--
website/package.json | 1 +
5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/packages/docusaurus-preset-bootstrap/package.json b/packages/docusaurus-preset-bootstrap/package.json
index 545c651d9e..69d6d74699 100644
--- a/packages/docusaurus-preset-bootstrap/package.json
+++ b/packages/docusaurus-preset-bootstrap/package.json
@@ -14,7 +14,9 @@
"@docusaurus/theme-bootstrap": "^2.0.0-alpha.55"
},
"peerDependencies": {
- "@docusaurus/core": "^2.0.0"
+ "@docusaurus/core": "^2.0.0",
+ "react": "^16.8.4",
+ "react-dom": "^16.8.4"
},
"engines": {
"node": ">=10.9.0"
diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json
index 47a3ead7dc..6245056ec4 100644
--- a/packages/docusaurus-preset-classic/package.json
+++ b/packages/docusaurus-preset-classic/package.json
@@ -18,7 +18,9 @@
"@docusaurus/theme-search-algolia": "^2.0.0-alpha.55"
},
"peerDependencies": {
- "@docusaurus/core": "^2.0.0"
+ "@docusaurus/core": "^2.0.0",
+ "react": "^16.8.4",
+ "react-dom": "^16.8.4"
},
"engines": {
"node": ">=10.9.0"
diff --git a/packages/docusaurus-theme-bootstrap/package.json b/packages/docusaurus-theme-bootstrap/package.json
index 1d33d05ad4..9d0e3ef1d2 100644
--- a/packages/docusaurus-theme-bootstrap/package.json
+++ b/packages/docusaurus-theme-bootstrap/package.json
@@ -17,8 +17,7 @@
"peerDependencies": {
"@docusaurus/core": "^2.0.0",
"react": "^16.8.4",
- "react-dom": "^16.8.4",
- "webpack": "^4.41.2"
+ "react-dom": "^16.8.4"
},
"engines": {
"node": ">=10.9.0"
diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json
index f7426641da..82fa70ab02 100644
--- a/packages/docusaurus-theme-classic/package.json
+++ b/packages/docusaurus-theme-classic/package.json
@@ -16,14 +16,14 @@
"parse-numeric-range": "^0.0.2",
"prism-react-renderer": "^1.1.0",
"prismjs": "^1.20.0",
+ "prop-types": "^15.7.2",
"react-router-dom": "^5.1.2",
"react-toggle": "^4.1.1"
},
"peerDependencies": {
"@docusaurus/core": "^2.0.0",
"react": "^16.8.4",
- "react-dom": "^16.8.4",
- "webpack": "^4.41.2"
+ "react-dom": "^16.8.4"
},
"engines": {
"node": ">=10.9.0"
diff --git a/website/package.json b/website/package.json
index 885ff449e3..bd33331a1d 100644
--- a/website/package.json
+++ b/website/package.json
@@ -10,6 +10,7 @@
},
"dependencies": {
"@docusaurus/core": "^2.0.0-alpha.55",
+ "@docusaurus/theme-live-codeblock": "^2.0.0-alpha.55",
"@docusaurus/plugin-ideal-image": "^2.0.0-alpha.55",
"@docusaurus/preset-classic": "^2.0.0-alpha.55",
"classnames": "^2.2.6",
From 4cc36a535eff333f7f6a499506d3585b899441e8 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sun, 24 May 2020 14:46:23 +0300
Subject: [PATCH 22/26] docs(v2): add trailing slash to external links (#2801)
---
website/docs/contributing.md | 10 +++++-----
website/docs/markdown-features.mdx | 2 +-
website/docs/migrating-from-v1-to-v2.md | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/website/docs/contributing.md b/website/docs/contributing.md
index b0d825e050..130a7f42a9 100644
--- a/website/docs/contributing.md
+++ b/website/docs/contributing.md
@@ -3,7 +3,7 @@ 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.
+[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:
@@ -48,7 +48,7 @@ We use [GitHub Issues](https://github.com/facebook/docusaurus/issues) for our pu
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)
+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
@@ -97,7 +97,7 @@ Use lower case not title case!
#### 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`.
+[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.
@@ -124,7 +124,7 @@ We have a list of [beginner friendly issues](https://github.com/facebook/docusau
### 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 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.
@@ -138,7 +138,7 @@ 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. 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).
diff --git a/website/docs/markdown-features.mdx b/website/docs/markdown-features.mdx
index a8a6c082bf..d4b74d2caf 100644
--- a/website/docs/markdown-features.mdx
+++ b/website/docs/markdown-features.mdx
@@ -140,7 +140,7 @@ One benefit of this approach is that the links to external files will still work
## Embedding React components with MDX
-Docusaurus has built-in support for [MDX](https://mdxjs.com), which allows you to write JSX within your Markdown files and render them as React components.
+Docusaurus has built-in support for [MDX](https://mdxjs.com/), which allows you to write JSX within your Markdown files and render them as React components.
**Note 1:** While both `.md` and `.mdx` files are parsed using MDX, some of the syntax are treated slightly differently. For the most accurate parsing and better editor support, we recommend using the `.mdx` extension for files containing MDX syntax. Let's rename the previous file to `greeting.mdx`.
diff --git a/website/docs/migrating-from-v1-to-v2.md b/website/docs/migrating-from-v1-to-v2.md
index 09b8feae5f..4b5e23c162 100644
--- a/website/docs/migrating-from-v1-to-v2.md
+++ b/website/docs/migrating-from-v1-to-v2.md
@@ -456,8 +456,8 @@ Please refer to [creating pages](creating-pages.md) to learn how Docusaurus 2 pa
The following code could be helpful for migration of various pages:
-- Index page - [Flux](https://github.com/facebook/flux/blob/master/website/src/pages/index.js) (recommended), [Docusaurus 2](https://github.com/facebook/docusaurus/blob/master/website/src/pages/index.js), [Hermes](https://github.com/facebook/hermes/blob/master/website/src/pages/index.js)
-- Help/Support page - [Docusaurus 2](https://github.com/facebook/docusaurus/blob/master/website/src/pages/help.js), [Flux](http://facebook.github.io/flux/support)
+- Index page - [Flux](https://github.com/facebook/flux/blob/master/website/src/pages/index.js/) (recommended), [Docusaurus 2](https://github.com/facebook/docusaurus/blob/master/website/src/pages/index.js/), [Hermes](https://github.com/facebook/hermes/blob/master/website/src/pages/index.js/)
+- Help/Support page - [Docusaurus 2](https://github.com/facebook/docusaurus/blob/master/website/src/pages/help.js/), [Flux](http://facebook.github.io/flux/support)
## Content
From ca90b429917b040048e71920828564898b49070a Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sun, 24 May 2020 14:47:04 +0300
Subject: [PATCH 23/26] misc: minor improvements for init templates (#2802)
---
.../docusaurus-init/templates/bootstrap/docs/doc1.md | 12 ++++++------
.../docusaurus-init/templates/bootstrap/docs/doc2.md | 2 +-
.../docusaurus-init/templates/bootstrap/docs/mdx.md | 2 +-
.../docusaurus-init/templates/classic/docs/doc1.md | 12 ++++++------
.../docusaurus-init/templates/classic/docs/doc2.md | 2 +-
.../docusaurus-init/templates/classic/docs/mdx.md | 2 +-
.../docusaurus-init/templates/facebook/docs/doc1.md | 12 ++++++------
.../docusaurus-init/templates/facebook/docs/doc2.md | 2 +-
.../docusaurus-init/templates/facebook/docs/mdx.md | 2 +-
9 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
index 448cb69a98..69bc29545b 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/doc1.md
@@ -57,9 +57,9 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Links
-[I'm an inline-style link](https://www.google.com)
+[I'm an inline-style link](https://www.google.com/)
-[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
+[I'm an inline-style link with title](https://www.google.com/ "Google's Homepage")
[I'm a reference-style link][arbitrary case-insensitive reference text]
@@ -69,13 +69,13 @@ Strikethrough uses two tildes. ~~Scratch this.~~
Or leave it empty and use the [link text itself].
-URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or and sometimes example.com (but not on Github, for example).
+URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com/ or and sometimes example.com (but not on GitHub, for example).
Some text to show that the reference links can follow later.
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com
+[arbitrary case-insensitive reference text]: https://www.mozilla.org/
+[1]: http://slashdot.org/
+[link text itself]: http://www.reddit.com/
---
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/doc2.md b/packages/docusaurus-init/templates/bootstrap/docs/doc2.md
index 2462b7f810..16cfce4082 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/doc2.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/doc2.md
@@ -3,4 +3,4 @@ id: doc2
title: Document Number 2
---
-This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com)
+This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com/)
diff --git a/packages/docusaurus-init/templates/bootstrap/docs/mdx.md b/packages/docusaurus-init/templates/bootstrap/docs/mdx.md
index 1462851227..f0210fb70d 100644
--- a/packages/docusaurus-init/templates/bootstrap/docs/mdx.md
+++ b/packages/docusaurus-init/templates/bootstrap/docs/mdx.md
@@ -10,7 +10,7 @@ export const Highlight = ({children, color}) => ( {children} );
+ }}>{children} );
Docusaurus green and Facebook blue are my favorite colors.
diff --git a/packages/docusaurus-init/templates/classic/docs/doc1.md b/packages/docusaurus-init/templates/classic/docs/doc1.md
index 448cb69a98..69bc29545b 100644
--- a/packages/docusaurus-init/templates/classic/docs/doc1.md
+++ b/packages/docusaurus-init/templates/classic/docs/doc1.md
@@ -57,9 +57,9 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Links
-[I'm an inline-style link](https://www.google.com)
+[I'm an inline-style link](https://www.google.com/)
-[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
+[I'm an inline-style link with title](https://www.google.com/ "Google's Homepage")
[I'm a reference-style link][arbitrary case-insensitive reference text]
@@ -69,13 +69,13 @@ Strikethrough uses two tildes. ~~Scratch this.~~
Or leave it empty and use the [link text itself].
-URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or and sometimes example.com (but not on Github, for example).
+URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com/ or and sometimes example.com (but not on GitHub, for example).
Some text to show that the reference links can follow later.
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com
+[arbitrary case-insensitive reference text]: https://www.mozilla.org/
+[1]: http://slashdot.org/
+[link text itself]: http://www.reddit.com/
---
diff --git a/packages/docusaurus-init/templates/classic/docs/doc2.md b/packages/docusaurus-init/templates/classic/docs/doc2.md
index 2462b7f810..16cfce4082 100644
--- a/packages/docusaurus-init/templates/classic/docs/doc2.md
+++ b/packages/docusaurus-init/templates/classic/docs/doc2.md
@@ -3,4 +3,4 @@ id: doc2
title: Document Number 2
---
-This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com)
+This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com/)
diff --git a/packages/docusaurus-init/templates/classic/docs/mdx.md b/packages/docusaurus-init/templates/classic/docs/mdx.md
index 1462851227..f0210fb70d 100644
--- a/packages/docusaurus-init/templates/classic/docs/mdx.md
+++ b/packages/docusaurus-init/templates/classic/docs/mdx.md
@@ -10,7 +10,7 @@ export const Highlight = ({children, color}) => ( {children} );
+ }}>{children} );
Docusaurus green and Facebook blue are my favorite colors.
diff --git a/packages/docusaurus-init/templates/facebook/docs/doc1.md b/packages/docusaurus-init/templates/facebook/docs/doc1.md
index 448cb69a98..69bc29545b 100644
--- a/packages/docusaurus-init/templates/facebook/docs/doc1.md
+++ b/packages/docusaurus-init/templates/facebook/docs/doc1.md
@@ -57,9 +57,9 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Links
-[I'm an inline-style link](https://www.google.com)
+[I'm an inline-style link](https://www.google.com/)
-[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
+[I'm an inline-style link with title](https://www.google.com/ "Google's Homepage")
[I'm a reference-style link][arbitrary case-insensitive reference text]
@@ -69,13 +69,13 @@ Strikethrough uses two tildes. ~~Scratch this.~~
Or leave it empty and use the [link text itself].
-URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or and sometimes example.com (but not on Github, for example).
+URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com/ or and sometimes example.com (but not on GitHub, for example).
Some text to show that the reference links can follow later.
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com
+[arbitrary case-insensitive reference text]: https://www.mozilla.org/
+[1]: http://slashdot.org/
+[link text itself]: http://www.reddit.com/
---
diff --git a/packages/docusaurus-init/templates/facebook/docs/doc2.md b/packages/docusaurus-init/templates/facebook/docs/doc2.md
index 2462b7f810..16cfce4082 100644
--- a/packages/docusaurus-init/templates/facebook/docs/doc2.md
+++ b/packages/docusaurus-init/templates/facebook/docs/doc2.md
@@ -3,4 +3,4 @@ id: doc2
title: Document Number 2
---
-This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com)
+This is a link to [another document.](doc3.md) This is a link to an [external page.](http://www.example.com/)
diff --git a/packages/docusaurus-init/templates/facebook/docs/mdx.md b/packages/docusaurus-init/templates/facebook/docs/mdx.md
index 1462851227..f0210fb70d 100644
--- a/packages/docusaurus-init/templates/facebook/docs/mdx.md
+++ b/packages/docusaurus-init/templates/facebook/docs/mdx.md
@@ -10,7 +10,7 @@ export const Highlight = ({children, color}) => ( {children} );
+ }}>{children} );
Docusaurus green and Facebook blue are my favorite colors.
From b52b7d64ff679c81259468ad6e5704edbae277b7 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Sun, 24 May 2020 15:08:42 +0300
Subject: [PATCH 24/26] fix(v2): make proper h1 font size on mobiles (#2800)
---
.../src/theme/DocItem/styles.module.css | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocItem/styles.module.css
index 5f2d8ce851..cf9e520511 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/styles.module.css
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/styles.module.css
@@ -7,14 +7,7 @@
.docTitle {
font-size: 3rem;
- margin-bottom: 3rem;
-}
-
-@media only screen and (max-width: 996px) {
- .docTitle {
- font-size: 2rem;
- margin-bottom: 2rem;
- }
+ margin-bottom: calc(var(--ifm-leading-desktop) * var(--ifm-leading));
}
.docItemContainer {
From 34e664ac277072319d49b263bb6761d1c424aff1 Mon Sep 17 00:00:00 2001
From: Sylvain Pace
Date: Mon, 25 May 2020 19:09:22 +0200
Subject: [PATCH 25/26] docs(v2): add mention on DocSearch when you run the
crawler on your own (#2809)
---
docs/guides-search.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/guides-search.md b/docs/guides-search.md
index c0b1c3365b..88b9bf10b6 100644
--- a/docs/guides-search.md
+++ b/docs/guides-search.md
@@ -17,6 +17,7 @@ const siteConfig = {
algolia: {
apiKey: 'my-api-key',
indexName: 'my-index-name',
+ appId: 'app-id', // Optional, if you run the DocSearch crawler on your own
algoliaOptions: {} // Optional, if provided by Algolia
},
...
From d391a2bcdbe7d5096d08be88d8bf5467e70264a8 Mon Sep 17 00:00:00 2001
From: Alexey Pyltsyn
Date: Mon, 25 May 2020 20:47:40 +0300
Subject: [PATCH 26/26] fix(v2): enable scrolling for sidebar menu only (#2645)
* fix(v2): enable scrolling for sidebar menu only
* Add support for announcement bar
* fix: remove redundant styles
---
.../src/theme/AnnouncementBar/index.js | 39 +++--------
.../theme/AnnouncementBar/styles.module.css | 11 +++
.../src/theme/AnnouncementBarContext.js | 15 ++++
.../theme/AnnouncementBarProvider/index.js | 24 +++++++
.../src/theme/DocSidebar/index.js | 11 ++-
.../src/theme/DocSidebar/styles.module.css | 16 ++++-
.../src/theme/Layout/index.js | 68 ++++++++++---------
.../src/theme/hooks/useAnnouncementBar.js | 52 ++++++++++++++
.../theme/hooks/useAnnouncementBarContext.js | 15 ++++
9 files changed, 186 insertions(+), 65 deletions(-)
create mode 100644 packages/docusaurus-theme-classic/src/theme/AnnouncementBarContext.js
create mode 100644 packages/docusaurus-theme-classic/src/theme/AnnouncementBarProvider/index.js
create mode 100644 packages/docusaurus-theme-classic/src/theme/hooks/useAnnouncementBar.js
create mode 100644 packages/docusaurus-theme-classic/src/theme/hooks/useAnnouncementBarContext.js
diff --git a/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/index.js b/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/index.js
index a1bc0359b3..475aaf51f1 100644
--- a/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/index.js
@@ -5,44 +5,23 @@
* LICENSE file in the root directory of this source tree.
*/
-import React, {useState, useEffect} from 'react';
+import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
+import useAnnouncementBarContext from '@theme/hooks/useAnnouncementBarContext';
import styles from './styles.module.css';
-const STORAGE_DISMISS_KEY = 'docusaurus.announcement.dismiss';
-const STORAGE_ID_KEY = 'docusaurus.announcement.id';
-
function AnnouncementBar() {
const {
siteConfig: {themeConfig: {announcementBar = {}}} = {},
} = useDocusaurusContext();
- const {id, content, backgroundColor, textColor} = announcementBar;
- const [isClosed, setClosed] = useState(true);
- const handleClose = () => {
- localStorage.setItem(STORAGE_DISMISS_KEY, true);
- setClosed(true);
- };
+ const {content, backgroundColor, textColor} = announcementBar;
+ const {
+ isAnnouncementBarClosed,
+ closeAnnouncementBar,
+ } = useAnnouncementBarContext();
- useEffect(() => {
- const viewedId = localStorage.getItem(STORAGE_ID_KEY);
- const isNewAnnouncement = id !== viewedId;
-
- localStorage.setItem(STORAGE_ID_KEY, id);
-
- if (isNewAnnouncement) {
- localStorage.setItem(STORAGE_DISMISS_KEY, false);
- }
-
- if (
- isNewAnnouncement ||
- localStorage.getItem(STORAGE_DISMISS_KEY) === 'false'
- ) {
- setClosed(false);
- }
- }, []);
-
- if (!content || isClosed) {
+ if (!content || isAnnouncementBarClosed) {
return null;
}
@@ -59,7 +38,7 @@ function AnnouncementBar() {
diff --git a/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/styles.module.css b/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/styles.module.css
index 6b4ca286e2..12350cc8ec 100644
--- a/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/styles.module.css
+++ b/packages/docusaurus-theme-classic/src/theme/AnnouncementBar/styles.module.css
@@ -5,13 +5,24 @@
* LICENSE file in the root directory of this source tree.
*/
+:root {
+ --docusaurus-announcement-bar-height: auto;
+}
+
.announcementBar {
position: relative;
width: 100%;
+ height: var(--docusaurus-announcement-bar-height);
background-color: var(--ifm-color-primary);
color: var(--ifm-color-black);
}
+@media screen and (min-width: 1024px) {
+ :root {
+ --docusaurus-announcement-bar-height: 30px;
+ }
+}
+
.announcementBarClose {
position: absolute;
right: 0;
diff --git a/packages/docusaurus-theme-classic/src/theme/AnnouncementBarContext.js b/packages/docusaurus-theme-classic/src/theme/AnnouncementBarContext.js
new file mode 100644
index 0000000000..1d1adbe889
--- /dev/null
+++ b/packages/docusaurus-theme-classic/src/theme/AnnouncementBarContext.js
@@ -0,0 +1,15 @@
+/**
+ * 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.
+ */
+
+import {createContext} from 'react';
+
+const AnnouncementBarContext = createContext({
+ isAnnouncementBarClosed: false,
+ closeAnnouncementBar: () => {},
+});
+
+export default AnnouncementBarContext;
diff --git a/packages/docusaurus-theme-classic/src/theme/AnnouncementBarProvider/index.js b/packages/docusaurus-theme-classic/src/theme/AnnouncementBarProvider/index.js
new file mode 100644
index 0000000000..e35dfdd1db
--- /dev/null
+++ b/packages/docusaurus-theme-classic/src/theme/AnnouncementBarProvider/index.js
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ */
+
+import React from 'react';
+
+import AnnouncementBarContext from '@theme/AnnouncementBarContext';
+import useAnnouncementBar from '@theme/hooks/useAnnouncementBar';
+
+function AnnouncementBarProvider(props) {
+ const {isAnnouncementBarClosed, closeAnnouncementBar} = useAnnouncementBar();
+
+ return (
+
+ {props.children}
+
+ );
+}
+
+export default AnnouncementBarProvider;
diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
index 623987d949..cad9db38d5 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
@@ -8,8 +8,10 @@
import React, {useState, useCallback} from 'react';
import classnames from 'classnames';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
+import useAnnouncementBarContext from '@theme/hooks/useAnnouncementBarContext';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import useLogo from '@theme/hooks/useLogo';
+import useScrollPosition from '@theme/hooks/useScrollPosition';
import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/isInternalUrl';
@@ -134,6 +136,8 @@ function DocSidebar(props) {
isClient,
} = useDocusaurusContext();
const {logoLink, logoLinkProps, logoImageUrl, logoAlt} = useLogo();
+ const {isAnnouncementBarClosed} = useAnnouncementBarContext();
+ const {scrollY} = useScrollPosition();
const {
docsSidebars,
@@ -163,7 +167,10 @@ function DocSidebar(props) {
}
return (
-