@docusaurus/theme-classic 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/getSwizzleConfig.js +14 -0
  2. package/lib/theme/AnnouncementBar/CloseButton/index.d.ts +9 -0
  3. package/lib/theme/AnnouncementBar/CloseButton/index.js +26 -0
  4. package/lib/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
  5. package/lib/theme/AnnouncementBar/Content/index.d.ts +9 -0
  6. package/lib/theme/AnnouncementBar/Content/index.js +23 -0
  7. package/lib/theme/AnnouncementBar/Content/styles.module.css +17 -0
  8. package/lib/theme/AnnouncementBar/index.js +10 -23
  9. package/lib/theme/AnnouncementBar/styles.module.css +9 -10
  10. package/lib/theme/CodeBlock/Line/index.js +2 -4
  11. package/lib/theme/CodeBlock/Line/styles.module.css +1 -0
  12. package/lib/theme/ColorModeToggle/index.js +2 -1
  13. package/lib/theme/DocCardList/index.d.ts +1 -1
  14. package/lib/theme/DocCardList/index.js +14 -11
  15. package/lib/theme/DocPage/index.js +24 -7
  16. package/lib/theme/DocSidebarItem/Category/index.js +1 -1
  17. package/lib/theme/DocSidebarItem/Link/index.js +2 -1
  18. package/lib/theme/Layout/index.js +6 -1
  19. package/lib/theme/MDXComponents/Code.js +24 -4
  20. package/lib/theme/MDXComponents/index.js +2 -0
  21. package/lib/theme/Mermaid.d.ts +7 -0
  22. package/lib/theme/Mermaid.js +13 -0
  23. package/lib/theme/Navbar/MobileSidebar/Header/index.js +6 -0
  24. package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +11 -6
  25. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +4 -1
  26. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +6 -1
  27. package/lib/theme/SkipToContent/index.js +2 -15
  28. package/lib/theme/Tabs/index.js +4 -1
  29. package/lib/theme/Tag/styles.module.css +2 -2
  30. package/package.json +14 -16
  31. package/src/getSwizzleConfig.ts +16 -0
  32. package/src/theme/AnnouncementBar/CloseButton/index.tsx +31 -0
  33. package/src/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
  34. package/src/theme/AnnouncementBar/Content/index.tsx +28 -0
  35. package/src/theme/AnnouncementBar/Content/styles.module.css +17 -0
  36. package/src/theme/AnnouncementBar/index.tsx +10 -26
  37. package/src/theme/AnnouncementBar/styles.module.css +9 -10
  38. package/src/theme/CodeBlock/Line/index.tsx +2 -4
  39. package/src/theme/CodeBlock/Line/styles.module.css +1 -0
  40. package/src/theme/ColorModeToggle/index.tsx +2 -1
  41. package/src/theme/DocCardList/index.tsx +14 -12
  42. package/src/theme/DocPage/index.tsx +25 -7
  43. package/src/theme/DocSidebarItem/Category/index.tsx +1 -1
  44. package/src/theme/DocSidebarItem/Link/index.tsx +2 -1
  45. package/src/theme/Layout/index.tsx +6 -1
  46. package/src/theme/MDXComponents/Code.tsx +24 -4
  47. package/src/theme/MDXComponents/index.tsx +2 -0
  48. package/src/theme/Mermaid.tsx +16 -0
  49. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +6 -0
  50. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +11 -6
  51. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +4 -1
  52. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +6 -1
  53. package/src/theme/SkipToContent/index.tsx +2 -15
  54. package/src/theme/Tabs/index.tsx +8 -2
  55. package/src/theme/Tag/styles.module.css +2 -2
  56. package/src/theme-classic.d.ts +27 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,18 +20,18 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "2.0.1",
24
- "@docusaurus/mdx-loader": "2.0.1",
25
- "@docusaurus/module-type-aliases": "2.0.1",
26
- "@docusaurus/plugin-content-blog": "2.0.1",
27
- "@docusaurus/plugin-content-docs": "2.0.1",
28
- "@docusaurus/plugin-content-pages": "2.0.1",
29
- "@docusaurus/theme-common": "2.0.1",
30
- "@docusaurus/theme-translations": "2.0.1",
31
- "@docusaurus/types": "2.0.1",
32
- "@docusaurus/utils": "2.0.1",
33
- "@docusaurus/utils-common": "2.0.1",
34
- "@docusaurus/utils-validation": "2.0.1",
23
+ "@docusaurus/core": "2.2.0",
24
+ "@docusaurus/mdx-loader": "2.2.0",
25
+ "@docusaurus/module-type-aliases": "2.2.0",
26
+ "@docusaurus/plugin-content-blog": "2.2.0",
27
+ "@docusaurus/plugin-content-docs": "2.2.0",
28
+ "@docusaurus/plugin-content-pages": "2.2.0",
29
+ "@docusaurus/theme-common": "2.2.0",
30
+ "@docusaurus/theme-translations": "2.2.0",
31
+ "@docusaurus/types": "2.2.0",
32
+ "@docusaurus/utils": "2.2.0",
33
+ "@docusaurus/utils-common": "2.2.0",
34
+ "@docusaurus/utils-validation": "2.2.0",
35
35
  "@mdx-js/react": "^1.6.22",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
@@ -47,8 +47,6 @@
47
47
  "utility-types": "^3.10.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@docusaurus/module-type-aliases": "2.0.0-beta.21",
51
- "@docusaurus/types": "2.0.0-beta.21",
52
50
  "@types/mdx-js__react": "^1.5.5",
53
51
  "@types/nprogress": "^0.2.0",
54
52
  "@types/prismjs": "^1.26.0",
@@ -64,5 +62,5 @@
64
62
  "engines": {
65
63
  "node": ">=16.14"
66
64
  },
67
- "gitHead": "1ddee1c29cabf9bb52e4d78af6ebfaaabb1bc1f9"
65
+ "gitHead": "a308fb7c81832cca354192fe2984f52749441249"
68
66
  }
@@ -28,6 +28,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
28
28
  description:
29
29
  'The color mode toggle to switch between light and dark mode.',
30
30
  },
31
+ DocCardList: {
32
+ actions: {
33
+ eject: 'safe',
34
+ wrap: 'safe',
35
+ },
36
+ description:
37
+ 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
38
+ },
31
39
  DocSidebar: {
32
40
  actions: {
33
41
  eject: 'unsafe', // Too much technical code in sidebar, not very safe atm
@@ -232,6 +240,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
232
240
  description:
233
241
  'The search bar component of your site, appearing in the navbar.',
234
242
  },
243
+ SkipToContent: {
244
+ actions: {
245
+ eject: 'safe',
246
+ wrap: 'safe',
247
+ },
248
+ description:
249
+ 'The component responsible for implementing the accessibility "skip to content" link (https://www.w3.org/TR/WCAG20-TECHS/G1.html)',
250
+ },
235
251
  'prism-include-languages': {
236
252
  actions: {
237
253
  eject: 'safe',
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import {translate} from '@docusaurus/Translate';
11
+ import IconClose from '@theme/Icon/Close';
12
+ import type {Props} from '@theme/AnnouncementBar/CloseButton';
13
+ import styles from './styles.module.css';
14
+
15
+ export default function AnnouncementBarCloseButton(
16
+ props: Props,
17
+ ): JSX.Element | null {
18
+ return (
19
+ <button
20
+ type="button"
21
+ aria-label={translate({
22
+ id: 'theme.AnnouncementBar.closeButtonAriaLabel',
23
+ message: 'Close',
24
+ description: 'The ARIA label for close button of announcement bar',
25
+ })}
26
+ {...props}
27
+ className={clsx('clean-btn close', styles.closeButton, props.className)}>
28
+ <IconClose width={14} height={14} strokeWidth={3.1} />
29
+ </button>
30
+ );
31
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .closeButton {
9
+ padding: 0;
10
+ line-height: 0;
11
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import {useThemeConfig} from '@docusaurus/theme-common';
11
+ import type {Props} from '@theme/AnnouncementBar/Content';
12
+ import styles from './styles.module.css';
13
+
14
+ export default function AnnouncementBarContent(
15
+ props: Props,
16
+ ): JSX.Element | null {
17
+ const {announcementBar} = useThemeConfig();
18
+ const {content} = announcementBar!;
19
+ return (
20
+ <div
21
+ {...props}
22
+ className={clsx(styles.content, props.className)}
23
+ // Developer provided the HTML, so assume it's safe.
24
+ // eslint-disable-next-line react/no-danger
25
+ dangerouslySetInnerHTML={{__html: content}}
26
+ />
27
+ );
28
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .content {
9
+ font-size: 85%;
10
+ text-align: center;
11
+ padding: 5px 0;
12
+ }
13
+
14
+ .content a {
15
+ color: inherit;
16
+ text-decoration: underline;
17
+ }
@@ -6,49 +6,33 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
9
  import {useThemeConfig} from '@docusaurus/theme-common';
11
10
  import {useAnnouncementBar} from '@docusaurus/theme-common/internal';
12
- import {translate} from '@docusaurus/Translate';
13
- import IconClose from '@theme/Icon/Close';
11
+ import AnnouncementBarCloseButton from '@theme/AnnouncementBar/CloseButton';
12
+ import AnnouncementBarContent from '@theme/AnnouncementBar/Content';
14
13
 
15
14
  import styles from './styles.module.css';
16
15
 
17
16
  export default function AnnouncementBar(): JSX.Element | null {
18
- const {isActive, close} = useAnnouncementBar();
19
17
  const {announcementBar} = useThemeConfig();
20
-
18
+ const {isActive, close} = useAnnouncementBar();
21
19
  if (!isActive) {
22
20
  return null;
23
21
  }
24
-
25
- const {content, backgroundColor, textColor, isCloseable} = announcementBar!;
26
-
22
+ const {backgroundColor, textColor, isCloseable} = announcementBar!;
27
23
  return (
28
24
  <div
29
25
  className={styles.announcementBar}
30
26
  style={{backgroundColor, color: textColor}}
31
27
  role="banner">
32
28
  {isCloseable && <div className={styles.announcementBarPlaceholder} />}
33
- <div
34
- className={styles.announcementBarContent}
35
- // Developer provided the HTML, so assume it's safe.
36
- // eslint-disable-next-line react/no-danger
37
- dangerouslySetInnerHTML={{__html: content}}
38
- />
39
- {isCloseable ? (
40
- <button
41
- type="button"
42
- className={clsx('clean-btn close', styles.announcementBarClose)}
29
+ <AnnouncementBarContent className={styles.announcementBarContent} />
30
+ {isCloseable && (
31
+ <AnnouncementBarCloseButton
43
32
  onClick={close}
44
- aria-label={translate({
45
- id: 'theme.AnnouncementBar.closeButtonAriaLabel',
46
- message: 'Close',
47
- description: 'The ARIA label for close button of announcement bar',
48
- })}>
49
- <IconClose width={14} height={14} strokeWidth={3.1} />
50
- </button>
51
- ) : null}
33
+ className={styles.announcementBarClose}
34
+ />
35
+ )}
52
36
  </div>
53
37
  );
54
38
  }
@@ -15,6 +15,15 @@
15
15
  height: var(--docusaurus-announcement-bar-height);
16
16
  background-color: var(--ifm-color-white);
17
17
  color: var(--ifm-color-black);
18
+
19
+ /*
20
+ Unfortunately we can't make announcement bar render above the navbar
21
+ IE need to use border-bottom instead of shadow
22
+ See https://github.com/facebookincubator/infima/issues/275
23
+
24
+ box-shadow: var(--ifm-global-shadow-lw);
25
+ z-index: calc(var(--ifm-z-index-fixed) + 1);
26
+ */
18
27
  border-bottom: 1px solid var(--ifm-color-emphasis-100);
19
28
  }
20
29
 
@@ -29,15 +38,10 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
29
38
  .announcementBarClose {
30
39
  flex: 0 0 30px;
31
40
  align-self: stretch;
32
- padding: 0;
33
- line-height: 0;
34
41
  }
35
42
 
36
43
  .announcementBarContent {
37
44
  flex: 1 1 auto;
38
- font-size: 85%;
39
- text-align: center;
40
- padding: 5px 0;
41
45
  }
42
46
 
43
47
  @media print {
@@ -46,11 +50,6 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
46
50
  }
47
51
  }
48
52
 
49
- .announcementBarContent a {
50
- color: inherit;
51
- text-decoration: underline;
52
- }
53
-
54
53
  @media (min-width: 997px) {
55
54
  :root {
56
55
  --docusaurus-announcement-bar-height: 30px;
@@ -39,11 +39,9 @@ export default function CodeBlockLine({
39
39
  <span className={styles.codeLineContent}>{lineTokens}</span>
40
40
  </>
41
41
  ) : (
42
- <>
43
- {lineTokens}
44
- <br />
45
- </>
42
+ lineTokens
46
43
  )}
44
+ <br />
47
45
  </span>
48
46
  );
49
47
  }
@@ -35,6 +35,7 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
35
35
  left: 0;
36
36
  padding: 0 var(--ifm-pre-padding);
37
37
  background: var(--ifm-pre-background);
38
+ overflow-wrap: normal;
38
39
  }
39
40
 
40
41
  .codeLineNumber::before {
@@ -52,7 +52,8 @@ function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
52
52
  onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
53
53
  disabled={!isBrowser}
54
54
  title={title}
55
- aria-label={title}>
55
+ aria-label={title}
56
+ aria-live="polite">
56
57
  <IconLightMode
57
58
  className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
58
59
  />
@@ -7,25 +7,27 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
10
+ import {
11
+ useCurrentSidebarCategory,
12
+ filterDocCardListItems,
13
+ } from '@docusaurus/theme-common';
11
14
  import DocCard from '@theme/DocCard';
12
15
  import type {Props} from '@theme/DocCardList';
13
- import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
14
16
 
15
- // Filter categories that don't have a link.
16
- function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
17
- return items.filter((item) => {
18
- if (item.type === 'category') {
19
- return !!findFirstCategoryLink(item);
20
- }
21
- return true;
22
- });
17
+ function DocCardListForCurrentSidebarCategory({className}: Props) {
18
+ const category = useCurrentSidebarCategory();
19
+ return <DocCardList items={category.items} className={className} />;
23
20
  }
24
21
 
25
- export default function DocCardList({items, className}: Props): JSX.Element {
22
+ export default function DocCardList(props: Props): JSX.Element {
23
+ const {items, className} = props;
24
+ if (!items) {
25
+ return <DocCardListForCurrentSidebarCategory {...props} />;
26
+ }
27
+ const filteredItems = filterDocCardListItems(items);
26
28
  return (
27
29
  <section className={clsx('row', className)}>
28
- {filterItems(items).map((item, index) => (
30
+ {filteredItems.map((item, index) => (
29
31
  <article key={index} className="col col--6 margin-bottom--lg">
30
32
  <DocCard item={item} />
31
33
  </article>
@@ -7,7 +7,11 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {
11
+ HtmlClassNameProvider,
12
+ ThemeClassNames,
13
+ PageMetadata,
14
+ } from '@docusaurus/theme-common';
11
15
  import {
12
16
  docVersionSearchTag,
13
17
  DocsSidebarProvider,
@@ -19,13 +23,8 @@ import NotFound from '@theme/NotFound';
19
23
  import SearchMetadata from '@theme/SearchMetadata';
20
24
  import type {Props} from '@theme/DocPage';
21
25
 
22
- export default function DocPage(props: Props): JSX.Element {
26
+ function DocPageMetadata(props: Props): JSX.Element {
23
27
  const {versionMetadata} = props;
24
- const currentDocRouteMetadata = useDocRouteMetadata(props);
25
- if (!currentDocRouteMetadata) {
26
- return <NotFound />;
27
- }
28
- const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
29
28
  return (
30
29
  <>
31
30
  <SearchMetadata
@@ -35,6 +34,25 @@ export default function DocPage(props: Props): JSX.Element {
35
34
  versionMetadata.version,
36
35
  )}
37
36
  />
37
+ <PageMetadata>
38
+ {versionMetadata.noIndex && (
39
+ <meta name="robots" content="noindex, nofollow" />
40
+ )}
41
+ </PageMetadata>
42
+ </>
43
+ );
44
+ }
45
+
46
+ export default function DocPage(props: Props): JSX.Element {
47
+ const {versionMetadata} = props;
48
+ const currentDocRouteMetadata = useDocRouteMetadata(props);
49
+ if (!currentDocRouteMetadata) {
50
+ return <NotFound />;
51
+ }
52
+ const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
53
+ return (
54
+ <>
55
+ <DocPageMetadata {...props} />
38
56
  <HtmlClassNameProvider
39
57
  className={clsx(
40
58
  // TODO: it should be removed from here
@@ -136,7 +136,7 @@ export default function DocSidebarItemCategory({
136
136
  useEffect(() => {
137
137
  if (
138
138
  collapsible &&
139
- expandedItem &&
139
+ expandedItem != null &&
140
140
  expandedItem !== index &&
141
141
  autoCollapseCategories
142
142
  ) {
@@ -24,7 +24,7 @@ export default function DocSidebarItemLink({
24
24
  index,
25
25
  ...props
26
26
  }: Props): JSX.Element {
27
- const {href, label, className} = item;
27
+ const {href, label, className, autoAddBaseUrl} = item;
28
28
  const isActive = isActiveSidebarItem(item, activePath);
29
29
  const isInternalLink = isInternalUrl(href);
30
30
  return (
@@ -44,6 +44,7 @@ export default function DocSidebarItemLink({
44
44
  'menu__link--active': isActive,
45
45
  },
46
46
  )}
47
+ autoAddBaseUrl={autoAddBaseUrl}
47
48
  aria-current={isActive ? 'page' : undefined}
48
49
  to={href}
49
50
  {...(isInternalLink && {
@@ -8,7 +8,11 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import ErrorBoundary from '@docusaurus/ErrorBoundary';
11
- import {PageMetadata, ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {
12
+ PageMetadata,
13
+ SkipToContentFallbackId,
14
+ ThemeClassNames,
15
+ } from '@docusaurus/theme-common';
12
16
  import {useKeyboardNavigation} from '@docusaurus/theme-common/internal';
13
17
  import SkipToContent from '@theme/SkipToContent';
14
18
  import AnnouncementBar from '@theme/AnnouncementBar';
@@ -42,6 +46,7 @@ export default function Layout(props: Props): JSX.Element {
42
46
  <Navbar />
43
47
 
44
48
  <div
49
+ id={SkipToContentFallbackId}
45
50
  className={clsx(
46
51
  ThemeClassNames.wrapper.main,
47
52
  styles.mainWrapper,
@@ -13,15 +13,35 @@ import type {Props} from '@theme/MDXComponents/Code';
13
13
  export default function MDXCode(props: Props): JSX.Element {
14
14
  const inlineElements: (string | undefined)[] = [
15
15
  'a',
16
+ 'abbr',
16
17
  'b',
17
- 'big',
18
+ 'br',
19
+ 'button',
20
+ 'cite',
21
+ 'code',
22
+ 'del',
23
+ 'dfn',
24
+ 'em',
18
25
  'i',
26
+ 'img',
27
+ 'input',
28
+ 'ins',
29
+ 'kbd',
30
+ 'label',
31
+ 'object',
32
+ 'output',
33
+ 'q',
34
+ 'ruby',
35
+ 's',
36
+ 'small',
19
37
  'span',
20
- 'em',
21
38
  'strong',
22
- 'sup',
23
39
  'sub',
24
- 'small',
40
+ 'sup',
41
+ 'time',
42
+ 'u',
43
+ 'var',
44
+ 'wbr',
25
45
  ];
26
46
  const shouldBeInline = React.Children.toArray(props.children).every(
27
47
  (el) =>
@@ -15,6 +15,7 @@ import MDXHeading from '@theme/MDXComponents/Heading';
15
15
  import MDXUl from '@theme/MDXComponents/Ul';
16
16
  import MDXImg from '@theme/MDXComponents/Img';
17
17
  import Admonition from '@theme/Admonition';
18
+ import Mermaid from '@theme/Mermaid';
18
19
 
19
20
  import type {MDXComponentsObject} from '@theme/MDXComponents';
20
21
 
@@ -33,6 +34,7 @@ const MDXComponents: MDXComponentsObject = {
33
34
  h5: (props) => <MDXHeading as="h5" {...props} />,
34
35
  h6: (props) => <MDXHeading as="h6" {...props} />,
35
36
  admonition: Admonition,
37
+ mermaid: Mermaid,
36
38
  };
37
39
 
38
40
  export default MDXComponents;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ // This component is meant to be implemented by a Mermaid renderer theme
9
+ // It is notable created to be overridden by docusaurus-theme-mermaid
10
+
11
+ // By default, the classic theme does not provide any Mermaid implementation
12
+ // Yet we declare it there so that we can register it in MDX
13
+ // TODO later the mermaid theme should be able to register its MDX component
14
+ // see https://github.com/facebook/docusaurus/pull/7490#issuecomment-1279117288
15
+
16
+ export {default} from '@docusaurus/Noop';
@@ -7,6 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
10
+ import {translate} from '@docusaurus/Translate';
10
11
  import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
11
12
  import IconClose from '@theme/Icon/Close';
12
13
  import NavbarLogo from '@theme/Navbar/Logo';
@@ -16,6 +17,11 @@ function CloseButton() {
16
17
  return (
17
18
  <button
18
19
  type="button"
20
+ aria-label={translate({
21
+ id: 'theme.docs.sidebar.closeSidebarButtonAriaLabel',
22
+ message: 'Close navigation bar',
23
+ description: 'The ARIA label for close button of mobile sidebar',
24
+ })}
19
25
  className="clean-btn navbar-sidebar__close"
20
26
  onClick={() => mobileSidebar.toggle()}>
21
27
  <IconClose color="var(--ifm-color-emphasis-600)" />
@@ -7,18 +7,23 @@
7
7
 
8
8
  import React from 'react';
9
9
  import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
10
+ import {translate} from '@docusaurus/Translate';
10
11
  import IconMenu from '@theme/Icon/Menu';
11
12
 
12
13
  export default function MobileSidebarToggle(): JSX.Element {
13
- const mobileSidebar = useNavbarMobileSidebar();
14
+ const {toggle, shown} = useNavbarMobileSidebar();
14
15
  return (
15
16
  <button
16
- onClick={mobileSidebar.toggle}
17
- onKeyDown={mobileSidebar.toggle}
18
- aria-label="Navigation bar toggle"
17
+ onClick={toggle}
18
+ aria-label={translate({
19
+ id: 'theme.docs.sidebar.toggleSidebarButtonAriaLabel',
20
+ message: 'Toggle navigation bar',
21
+ description:
22
+ 'The ARIA label for hamburger menu button of mobile navigation',
23
+ })}
24
+ aria-expanded={shown}
19
25
  className="navbar__toggle clean-btn"
20
- type="button"
21
- tabIndex={0}>
26
+ type="button">
22
27
  <IconMenu />
23
28
  </button>
24
29
  );
@@ -13,6 +13,7 @@ import {
13
13
  import {useDocsPreferredVersion} from '@docusaurus/theme-common';
14
14
  import {useDocsVersionCandidates} from '@docusaurus/theme-common/internal';
15
15
  import {translate} from '@docusaurus/Translate';
16
+ import {useLocation} from '@docusaurus/router';
16
17
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
17
18
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
18
19
  import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
@@ -29,6 +30,7 @@ export default function DocsVersionDropdownNavbarItem({
29
30
  dropdownItemsAfter,
30
31
  ...props
31
32
  }: Props): JSX.Element {
33
+ const {search, hash} = useLocation();
32
34
  const activeDocContext = useActiveDocContext(docsPluginId);
33
35
  const versions = useVersions(docsPluginId);
34
36
  const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
@@ -40,7 +42,8 @@ export default function DocsVersionDropdownNavbarItem({
40
42
  getVersionMainDoc(version);
41
43
  return {
42
44
  label: version.label,
43
- to: versionDoc.path,
45
+ // preserve ?search#hash suffix on version switches
46
+ to: `${versionDoc.path}${search}${hash}`,
44
47
  isActive: () => version === activeDocContext.activeVersion,
45
48
  onClick: () => savePreferredVersionName(version.name),
46
49
  };
@@ -9,6 +9,7 @@ import React from 'react';
9
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
10
  import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
11
11
  import {translate} from '@docusaurus/Translate';
12
+ import {useLocation} from '@docusaurus/router';
12
13
  import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
13
14
  import IconLanguage from '@theme/Icon/Language';
14
15
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
@@ -26,14 +27,18 @@ export default function LocaleDropdownNavbarItem({
26
27
  i18n: {currentLocale, locales, localeConfigs},
27
28
  } = useDocusaurusContext();
28
29
  const alternatePageUtils = useAlternatePageUtils();
30
+ const {search, hash} = useLocation();
29
31
 
30
32
  const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
31
- const to = `pathname://${alternatePageUtils.createUrl({
33
+ const baseTo = `pathname://${alternatePageUtils.createUrl({
32
34
  locale,
33
35
  fullyQualified: false,
34
36
  })}`;
37
+ // preserve ?search#hash suffix on locale switches
38
+ const to = `${baseTo}${search}${hash}`;
35
39
  return {
36
40
  label: localeConfigs[locale]!.label,
41
+ lang: localeConfigs[locale]!.htmlLang,
37
42
  to,
38
43
  target: '_self',
39
44
  autoAddBaseUrl: false,