@docusaurus/theme-classic 2.4.0 → 3.0.0-alpha.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 (170) hide show
  1. package/lib/getSwizzleConfig.js +99 -7
  2. package/lib/index.js +20 -6
  3. package/lib/nprogress.d.ts +1 -1
  4. package/lib/options.js +1 -0
  5. package/lib/theme/Admonition/Icon/Caution.d.ts +9 -0
  6. package/lib/theme/Admonition/Icon/Caution.js +17 -0
  7. package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
  8. package/lib/theme/Admonition/Icon/Danger.js +17 -0
  9. package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
  10. package/lib/theme/Admonition/Icon/Info.js +17 -0
  11. package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
  12. package/lib/theme/Admonition/Icon/Note.js +17 -0
  13. package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
  14. package/lib/theme/Admonition/Icon/Tip.js +17 -0
  15. package/lib/theme/Admonition/Layout/index.d.ts +9 -0
  16. package/lib/theme/Admonition/Layout/index.js +45 -0
  17. package/lib/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  18. package/lib/theme/Admonition/Type/Caution.d.ts +9 -0
  19. package/lib/theme/Admonition/Type/Caution.js +32 -0
  20. package/lib/theme/Admonition/Type/Danger.d.ts +9 -0
  21. package/lib/theme/Admonition/Type/Danger.js +32 -0
  22. package/lib/theme/Admonition/Type/Info.d.ts +9 -0
  23. package/lib/theme/Admonition/Type/Info.js +32 -0
  24. package/lib/theme/Admonition/Type/Note.d.ts +9 -0
  25. package/lib/theme/Admonition/Type/Note.js +32 -0
  26. package/lib/theme/Admonition/Type/Tip.d.ts +9 -0
  27. package/lib/theme/Admonition/Type/Tip.js +32 -0
  28. package/lib/theme/Admonition/Types.d.ts +12 -0
  29. package/lib/theme/Admonition/Types.js +33 -0
  30. package/lib/theme/Admonition/index.d.ts +1 -1
  31. package/lib/theme/Admonition/index.js +12 -171
  32. package/lib/theme/BlogArchivePage/index.js +7 -2
  33. package/lib/theme/BlogPostPage/index.js +3 -1
  34. package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
  35. package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
  36. package/lib/theme/BlogTagsListPage/index.js +2 -1
  37. package/lib/theme/BlogTagsPostsPage/index.js +4 -2
  38. package/lib/theme/CodeBlock/CopyButton/index.js +4 -6
  39. package/lib/theme/CodeBlock/WordWrapButton/index.js +2 -9
  40. package/lib/theme/DocBreadcrumbs/index.js +6 -2
  41. package/lib/theme/DocCard/index.js +8 -4
  42. package/lib/theme/DocItem/Layout/index.js +5 -0
  43. package/lib/theme/DocPaginator/index.js +1 -1
  44. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
  45. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
  46. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
  47. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
  48. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
  49. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +8 -3
  50. package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
  51. package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
  52. package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  53. package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
  54. package/lib/theme/DocRoot/index.js +31 -0
  55. package/lib/theme/DocSidebarItem/Category/index.js +3 -3
  56. package/lib/theme/DocSidebarItems/index.js +6 -4
  57. package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
  58. package/lib/theme/DocTagDocListPage/index.js +53 -39
  59. package/lib/theme/DocTagsListPage/index.d.ts +1 -1
  60. package/lib/theme/DocTagsListPage/index.js +26 -17
  61. package/lib/theme/DocVersionRoot/index.d.ts +10 -0
  62. package/lib/theme/DocVersionRoot/index.js +46 -0
  63. package/lib/theme/DocsRoot/index.d.ts +10 -0
  64. package/lib/theme/DocsRoot/index.js +18 -0
  65. package/lib/theme/EditThisPage/index.js +3 -6
  66. package/lib/theme/ErrorPageContent.js +3 -2
  67. package/lib/theme/{MDXComponents/Head.d.ts → Icon/Copy/index.d.ts} +2 -2
  68. package/lib/theme/Icon/Copy/index.js +17 -0
  69. package/lib/theme/Icon/Success/index.d.ts +9 -0
  70. package/lib/theme/Icon/Success/index.js +17 -0
  71. package/lib/theme/Icon/WordWrap/index.d.ts +9 -0
  72. package/lib/theme/Icon/WordWrap/index.js +17 -0
  73. package/lib/theme/MDXComponents/Code.js +2 -36
  74. package/lib/theme/MDXComponents/Details.js +1 -1
  75. package/lib/theme/MDXComponents/Pre.d.ts +2 -2
  76. package/lib/theme/MDXComponents/Pre.js +4 -11
  77. package/lib/theme/MDXComponents/index.js +3 -3
  78. package/lib/theme/MDXContent/index.js +1 -0
  79. package/lib/theme/MDXPage/index.js +16 -4
  80. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
  81. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
  82. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
  83. package/lib/theme/NotFound/Content/index.d.ts +9 -0
  84. package/lib/theme/NotFound/Content/index.js +42 -0
  85. package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
  86. package/lib/theme/NotFound/index.js +25 -0
  87. package/lib/theme/TOCItems/Tree.js +3 -4
  88. package/lib/theme/Tabs/index.js +4 -2
  89. package/lib/theme/TagsListByLetter/index.js +4 -1
  90. package/lib/theme/ThemedImage/index.js +8 -24
  91. package/lib/theme/Unlisted/index.d.ts +9 -0
  92. package/lib/theme/Unlisted/index.js +38 -0
  93. package/package.json +24 -24
  94. package/src/getSwizzleConfig.ts +107 -8
  95. package/src/index.ts +21 -6
  96. package/src/nprogress.ts +2 -1
  97. package/src/options.ts +1 -0
  98. package/src/theme/Admonition/Icon/Caution.tsx +20 -0
  99. package/src/theme/Admonition/Icon/Danger.tsx +20 -0
  100. package/src/theme/Admonition/Icon/Info.tsx +20 -0
  101. package/src/theme/Admonition/Icon/Note.tsx +20 -0
  102. package/src/theme/Admonition/Icon/Tip.tsx +20 -0
  103. package/src/theme/Admonition/Layout/index.tsx +57 -0
  104. package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  105. package/src/theme/Admonition/Type/Caution.tsx +37 -0
  106. package/src/theme/Admonition/Type/Danger.tsx +37 -0
  107. package/src/theme/Admonition/Type/Info.tsx +37 -0
  108. package/src/theme/Admonition/Type/Note.tsx +37 -0
  109. package/src/theme/Admonition/Type/Tip.tsx +37 -0
  110. package/src/theme/Admonition/Types.tsx +38 -0
  111. package/src/theme/Admonition/index.tsx +13 -194
  112. package/src/theme/BlogArchivePage/index.tsx +7 -2
  113. package/src/theme/BlogPostPage/index.tsx +3 -1
  114. package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
  115. package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
  116. package/src/theme/BlogTagsListPage/index.tsx +2 -1
  117. package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
  118. package/src/theme/CodeBlock/CopyButton/index.tsx +4 -6
  119. package/src/theme/CodeBlock/WordWrapButton/index.tsx +2 -9
  120. package/src/theme/DocBreadcrumbs/index.tsx +6 -2
  121. package/src/theme/DocCard/index.tsx +11 -6
  122. package/src/theme/DocItem/Layout/index.tsx +5 -0
  123. package/src/theme/DocPaginator/index.tsx +1 -1
  124. package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
  125. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
  126. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +9 -4
  127. package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
  128. package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  129. package/src/theme/DocRoot/index.tsx +34 -0
  130. package/src/theme/DocSidebarItem/Category/index.tsx +3 -3
  131. package/src/theme/DocSidebarItems/index.tsx +6 -4
  132. package/src/theme/DocTagDocListPage/index.tsx +60 -39
  133. package/src/theme/DocTagsListPage/index.tsx +33 -17
  134. package/src/theme/DocVersionRoot/index.tsx +51 -0
  135. package/src/theme/DocsRoot/index.tsx +22 -0
  136. package/src/theme/EditThisPage/index.tsx +3 -6
  137. package/src/theme/ErrorPageContent.tsx +3 -2
  138. package/src/theme/Icon/Copy/index.tsx +20 -0
  139. package/src/theme/Icon/Success/index.tsx +20 -0
  140. package/src/theme/Icon/WordWrap/index.tsx +20 -0
  141. package/src/theme/MDXComponents/Code.tsx +2 -39
  142. package/src/theme/MDXComponents/Details.tsx +1 -2
  143. package/src/theme/MDXComponents/Pre.tsx +5 -13
  144. package/src/theme/MDXComponents/index.tsx +3 -3
  145. package/src/theme/MDXContent/index.tsx +1 -0
  146. package/src/theme/MDXPage/index.tsx +16 -4
  147. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
  148. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
  149. package/src/theme/NotFound/Content/index.tsx +45 -0
  150. package/src/theme/NotFound/index.tsx +27 -0
  151. package/src/theme/SkipToContent/index.tsx +0 -1
  152. package/src/theme/TOCItems/Tree.tsx +3 -4
  153. package/src/theme/Tabs/index.tsx +4 -2
  154. package/src/theme/TagsListByLetter/index.tsx +4 -2
  155. package/src/theme/ThemedImage/index.tsx +8 -31
  156. package/src/theme/Unlisted/index.tsx +42 -0
  157. package/src/theme/prism-include-languages.ts +2 -1
  158. package/src/theme-classic.d.ts +154 -20
  159. package/lib/theme/DocPage/index.js +0 -67
  160. package/lib/theme/MDXComponents/Head.js +0 -23
  161. package/lib/theme/NotFound.js +0 -52
  162. package/src/theme/DocPage/index.tsx +0 -71
  163. package/src/theme/MDXComponents/Head.tsx +0 -29
  164. package/src/theme/NotFound.tsx +0 -54
  165. /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  166. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  167. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
  168. /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  169. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  170. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
@@ -0,0 +1,22 @@
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 {ThemeClassNames, HtmlClassNameProvider} from '@docusaurus/theme-common';
11
+ import renderRoutes from '@docusaurus/renderRoutes';
12
+ import Layout from '@theme/Layout';
13
+
14
+ import type {Props} from '@theme/DocVersionRoot';
15
+
16
+ export default function DocsRoot(props: Props): JSX.Element {
17
+ return (
18
+ <HtmlClassNameProvider className={clsx(ThemeClassNames.wrapper.docsPages)}>
19
+ <Layout>{renderRoutes(props.route.routes!)}</Layout>
20
+ </HtmlClassNameProvider>
21
+ );
22
+ }
@@ -8,22 +8,19 @@
8
8
  import React from 'react';
9
9
  import Translate from '@docusaurus/Translate';
10
10
  import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import Link from '@docusaurus/Link';
11
12
  import IconEdit from '@theme/Icon/Edit';
12
13
  import type {Props} from '@theme/EditThisPage';
13
14
 
14
15
  export default function EditThisPage({editUrl}: Props): JSX.Element {
15
16
  return (
16
- <a
17
- href={editUrl}
18
- target="_blank"
19
- rel="noreferrer noopener"
20
- className={ThemeClassNames.common.editThisPage}>
17
+ <Link to={editUrl} className={ThemeClassNames.common.editThisPage}>
21
18
  <IconEdit />
22
19
  <Translate
23
20
  id="theme.common.editThisPage"
24
21
  description="The link label to edit the current page">
25
22
  Edit this page
26
23
  </Translate>
27
- </a>
24
+ </Link>
28
25
  );
29
26
  }
@@ -12,6 +12,7 @@ import {
12
12
  ErrorBoundaryTryAgainButton,
13
13
  } from '@docusaurus/theme-common';
14
14
  import type {Props} from '@theme/Error';
15
+ import Heading from '@theme/Heading';
15
16
 
16
17
  export default function ErrorPageContent({
17
18
  error,
@@ -21,13 +22,13 @@ export default function ErrorPageContent({
21
22
  <main className="container margin-vert--xl">
22
23
  <div className="row">
23
24
  <div className="col col--6 col--offset-3">
24
- <h1 className="hero__title">
25
+ <Heading as="h1" className="hero__title">
25
26
  <Translate
26
27
  id="theme.ErrorPageContent.title"
27
28
  description="The title of the fallback page when the page crashed">
28
29
  This page crashed.
29
30
  </Translate>
30
- </h1>
31
+ </Heading>
31
32
  <div className="margin-vert--lg">
32
33
  <ErrorBoundaryTryAgainButton
33
34
  onClick={tryAgain}
@@ -0,0 +1,20 @@
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 type {Props} from '@theme/Icon/Copy';
10
+
11
+ export default function IconCopy(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 24 24" {...props}>
14
+ <path
15
+ fill="currentColor"
16
+ d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
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 type {Props} from '@theme/Icon/Success';
10
+
11
+ export default function IconSuccess(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 24 24" {...props}>
14
+ <path
15
+ fill="currentColor"
16
+ d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
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 type {Props} from '@theme/Icon/WordWrap';
10
+
11
+ export default function IconWordWrap(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 24 24" {...props}>
14
+ <path
15
+ fill="currentColor"
16
+ d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -6,50 +6,13 @@
6
6
  */
7
7
 
8
8
  import type {ComponentProps} from 'react';
9
- import React, {isValidElement} from 'react';
9
+ import React from 'react';
10
10
  import CodeBlock from '@theme/CodeBlock';
11
11
  import type {Props} from '@theme/MDXComponents/Code';
12
12
 
13
13
  export default function MDXCode(props: Props): JSX.Element {
14
- const inlineElements: (string | undefined)[] = [
15
- 'a',
16
- 'abbr',
17
- 'b',
18
- 'br',
19
- 'button',
20
- 'cite',
21
- 'code',
22
- 'del',
23
- 'dfn',
24
- 'em',
25
- 'i',
26
- 'img',
27
- 'input',
28
- 'ins',
29
- 'kbd',
30
- 'label',
31
- 'object',
32
- 'output',
33
- 'q',
34
- 'ruby',
35
- 's',
36
- 'small',
37
- 'span',
38
- 'strong',
39
- 'sub',
40
- 'sup',
41
- 'time',
42
- 'u',
43
- 'var',
44
- 'wbr',
45
- ];
46
14
  const shouldBeInline = React.Children.toArray(props.children).every(
47
- (el) =>
48
- (typeof el === 'string' && !el.includes('\n')) ||
49
- (isValidElement(el) &&
50
- inlineElements.includes(
51
- (el.props as {mdxType: string} | null)?.mdxType,
52
- )),
15
+ (el) => typeof el === 'string' && !el.includes('\n'),
53
16
  );
54
17
 
55
18
  return shouldBeInline ? (
@@ -15,8 +15,7 @@ export default function MDXDetails(props: Props): JSX.Element {
15
15
  // Details theme component
16
16
  const summary = items.find(
17
17
  (item): item is ReactElement<ComponentProps<'summary'>> =>
18
- React.isValidElement(item) &&
19
- (item.props as {mdxType: string} | null)?.mdxType === 'summary',
18
+ React.isValidElement(item) && item.type === 'summary',
20
19
  );
21
20
  const children = <>{items.filter((item) => item !== summary)}</>;
22
21
 
@@ -5,19 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {isValidElement} from 'react';
9
- import CodeBlock from '@theme/CodeBlock';
8
+ import React, {type ReactNode} from 'react';
10
9
  import type {Props} from '@theme/MDXComponents/Pre';
11
10
 
12
- export default function MDXPre(props: Props): JSX.Element {
13
- return (
14
- <CodeBlock
15
- // If this pre is created by a ``` fenced codeblock, unwrap the children
16
- {...(isValidElement(props.children) &&
17
- (props.children.props as {originalType: string} | null)?.originalType ===
18
- 'code'
19
- ? props.children.props
20
- : {...props})}
21
- />
22
- );
11
+ export default function MDXPre(props: Props): ReactNode | undefined {
12
+ // With MDX 2, this element is only used for fenced code blocks
13
+ // It always receives a MDXComponents/Code as children
14
+ return <>{props.children}</>;
23
15
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import MDXHead from '@theme/MDXComponents/Head';
9
+ import Head from '@docusaurus/Head';
10
10
  import MDXCode from '@theme/MDXComponents/Code';
11
11
  import MDXA from '@theme/MDXComponents/A';
12
12
  import MDXPre from '@theme/MDXComponents/Pre';
@@ -20,11 +20,11 @@ import Mermaid from '@theme/Mermaid';
20
20
  import type {MDXComponentsObject} from '@theme/MDXComponents';
21
21
 
22
22
  const MDXComponents: MDXComponentsObject = {
23
- head: MDXHead,
23
+ Head,
24
+ Details: MDXDetails,
24
25
  code: MDXCode,
25
26
  a: MDXA,
26
27
  pre: MDXPre,
27
- details: MDXDetails,
28
28
  ul: MDXUl,
29
29
  img: MDXImg,
30
30
  h1: (props) => <MDXHeading as="h1" {...props} />,
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ // @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
9
10
  import {MDXProvider} from '@mdx-js/react';
10
11
  import MDXComponents from '@theme/MDXComponents';
11
12
  import type {Props} from '@theme/MDXContent';
@@ -15,6 +15,7 @@ import {
15
15
  import Layout from '@theme/Layout';
16
16
  import MDXContent from '@theme/MDXContent';
17
17
  import TOC from '@theme/TOC';
18
+ import Unlisted from '@theme/Unlisted';
18
19
  import type {Props} from '@theme/MDXPage';
19
20
 
20
21
  import styles from './styles.module.css';
@@ -22,10 +23,15 @@ import styles from './styles.module.css';
22
23
  export default function MDXPage(props: Props): JSX.Element {
23
24
  const {content: MDXPageContent} = props;
24
25
  const {
25
- metadata: {title, description, frontMatter},
26
+ metadata: {title, description, frontMatter, unlisted},
27
+ assets,
26
28
  } = MDXPageContent;
27
- const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
28
- frontMatter;
29
+ const {
30
+ keywords,
31
+ wrapperClassName,
32
+ hide_table_of_contents: hideTableOfContents,
33
+ } = frontMatter;
34
+ const image = assets.image ?? frontMatter.image;
29
35
 
30
36
  return (
31
37
  <HtmlClassNameProvider
@@ -33,11 +39,17 @@ export default function MDXPage(props: Props): JSX.Element {
33
39
  wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
34
40
  ThemeClassNames.page.mdxPage,
35
41
  )}>
36
- <PageMetadata title={title} description={description} />
37
42
  <Layout>
43
+ <PageMetadata
44
+ title={title}
45
+ description={description}
46
+ keywords={keywords}
47
+ image={image}
48
+ />
38
49
  <main className="container container--fluid margin-vert--lg">
39
50
  <div className={clsx('row', styles.mdxPageWrapper)}>
40
51
  <div className={clsx('col', !hideTableOfContents && 'col--8')}>
52
+ {unlisted && <Unlisted />}
41
53
  <article>
42
54
  <MDXContent>
43
55
  <MDXPageContent />
@@ -19,9 +19,10 @@ export default function DocNavbarItem({
19
19
  }: Props): JSX.Element | null {
20
20
  const {activeDoc} = useActiveDocContext(docsPluginId);
21
21
  const doc = useLayoutDoc(docId, docsPluginId);
22
+ const pageActive = activeDoc?.path === doc?.path;
22
23
 
23
- // Draft items are not displayed in the navbar.
24
- if (doc === null) {
24
+ // Draft and unlisted items are not displayed in the navbar.
25
+ if (doc === null || (doc.unlisted && !pageActive)) {
25
26
  return null;
26
27
  }
27
28
 
@@ -30,7 +31,7 @@ export default function DocNavbarItem({
30
31
  exact
31
32
  {...props}
32
33
  isActive={() =>
33
- activeDoc?.path === doc.path ||
34
+ pageActive ||
34
35
  (!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
35
36
  }
36
37
  label={staticLabel ?? doc.id}
@@ -21,6 +21,7 @@ export default function LocaleDropdownNavbarItem({
21
21
  mobile,
22
22
  dropdownItemsBefore,
23
23
  dropdownItemsAfter,
24
+ queryString = '',
24
25
  ...props
25
26
  }: Props): JSX.Element {
26
27
  const {
@@ -35,7 +36,7 @@ export default function LocaleDropdownNavbarItem({
35
36
  fullyQualified: false,
36
37
  })}`;
37
38
  // preserve ?search#hash suffix on locale switches
38
- const to = `${baseTo}${search}${hash}`;
39
+ const to = `${baseTo}${search}${hash}${queryString}`;
39
40
  return {
40
41
  label: localeConfigs[locale]!.label,
41
42
  lang: localeConfigs[locale]!.htmlLang,
@@ -0,0 +1,45 @@
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 type {Props} from '@theme/NotFound/Content';
12
+ import Heading from '@theme/Heading';
13
+
14
+ export default function NotFoundContent({className}: Props): JSX.Element {
15
+ return (
16
+ <main className={clsx('container margin-vert--xl', className)}>
17
+ <div className="row">
18
+ <div className="col col--6 col--offset-3">
19
+ <Heading as="h1" className="hero__title">
20
+ <Translate
21
+ id="theme.NotFound.title"
22
+ description="The title of the 404 page">
23
+ Page Not Found
24
+ </Translate>
25
+ </Heading>
26
+ <p>
27
+ <Translate
28
+ id="theme.NotFound.p1"
29
+ description="The first paragraph of the 404 page">
30
+ We could not find what you were looking for.
31
+ </Translate>
32
+ </p>
33
+ <p>
34
+ <Translate
35
+ id="theme.NotFound.p2"
36
+ description="The 2nd paragraph of the 404 page">
37
+ Please contact the owner of the site that linked you to the
38
+ original URL and let them know their link is broken.
39
+ </Translate>
40
+ </p>
41
+ </div>
42
+ </div>
43
+ </main>
44
+ );
45
+ }
@@ -0,0 +1,27 @@
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 {translate} from '@docusaurus/Translate';
10
+ import {PageMetadata} from '@docusaurus/theme-common';
11
+ import Layout from '@theme/Layout';
12
+ import NotFoundContent from '@theme/NotFound/Content';
13
+
14
+ export default function Index(): JSX.Element {
15
+ const title = translate({
16
+ id: 'theme.NotFound.title',
17
+ message: 'Page Not Found',
18
+ });
19
+ return (
20
+ <>
21
+ <PageMetadata title={title} />
22
+ <Layout>
23
+ <NotFoundContent />
24
+ </Layout>
25
+ </>
26
+ );
27
+ }
@@ -7,7 +7,6 @@
7
7
 
8
8
  import React from 'react';
9
9
  import {SkipToContentLink} from '@docusaurus/theme-common';
10
-
11
10
  import styles from './styles.module.css';
12
11
 
13
12
  export default function SkipToContent(): JSX.Element {
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import Link from '@docusaurus/Link';
9
10
  import type {Props} from '@theme/TOCItems/Tree';
10
11
 
11
12
  // Recursive component rendering the toc tree
@@ -22,12 +23,10 @@ function TOCItemTree({
22
23
  <ul className={isChild ? undefined : className}>
23
24
  {toc.map((heading) => (
24
25
  <li key={heading.id}>
25
- {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
26
- <a
27
- href={`#${heading.id}`}
26
+ <Link
27
+ to={`#${heading.id}`}
28
28
  className={linkClassName ?? undefined}
29
29
  // Developer provided the HTML, so assume it's safe.
30
- // eslint-disable-next-line react/no-danger
31
30
  dangerouslySetInnerHTML={{__html: heading.value}}
32
31
  />
33
32
  <TOCItemTree
@@ -10,6 +10,7 @@ import clsx from 'clsx';
10
10
  import {
11
11
  useScrollPositionBlocker,
12
12
  useTabs,
13
+ sanitizeTabsChildren,
13
14
  type TabItemProps,
14
15
  } from '@docusaurus/theme-common/internal';
15
16
  import useIsBrowser from '@docusaurus/useIsBrowser';
@@ -152,7 +153,8 @@ export default function Tabs(props: Props): JSX.Element {
152
153
  // Remount tabs after hydration
153
154
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
154
155
  key={String(isBrowser)}
155
- {...props}
156
- />
156
+ {...props}>
157
+ {sanitizeTabsChildren(props.children)}
158
+ </TabsComponent>
157
159
  );
158
160
  }
@@ -9,13 +9,15 @@ import React from 'react';
9
9
  import {listTagsByLetters, type TagLetterEntry} from '@docusaurus/theme-common';
10
10
  import Tag from '@theme/Tag';
11
11
  import type {Props} from '@theme/TagsListByLetter';
12
-
12
+ import Heading from '@theme/Heading';
13
13
  import styles from './styles.module.css';
14
14
 
15
15
  function TagLetterEntryItem({letterEntry}: {letterEntry: TagLetterEntry}) {
16
16
  return (
17
17
  <article>
18
- <h2>{letterEntry.letter}</h2>
18
+ <Heading as="h2" id={letterEntry.letter}>
19
+ {letterEntry.letter}
20
+ </Heading>
19
21
  <ul className="padding--none">
20
22
  {letterEntry.tags.map((tag) => (
21
23
  <li key={tag.permalink} className={styles.tag}>
@@ -6,44 +6,21 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
- import useIsBrowser from '@docusaurus/useIsBrowser';
11
- import {useColorMode} from '@docusaurus/theme-common';
9
+ import {ThemedComponent} from '@docusaurus/theme-common';
12
10
  import type {Props} from '@theme/ThemedImage';
13
11
 
14
- import styles from './styles.module.css';
15
-
16
12
  export default function ThemedImage(props: Props): JSX.Element {
17
- const isBrowser = useIsBrowser();
18
- const {colorMode} = useColorMode();
19
- const {sources, className, alt, ...propsRest} = props;
20
-
21
- type SourceName = keyof Props['sources'];
22
-
23
- const clientThemes: SourceName[] =
24
- colorMode === 'dark' ? ['dark'] : ['light'];
25
-
26
- const renderedSourceNames: SourceName[] = isBrowser
27
- ? clientThemes
28
- : // We need to render both images on the server to avoid flash
29
- // See https://github.com/facebook/docusaurus/pull/3730
30
- ['light', 'dark'];
31
-
13
+ const {sources, className: parentClassName, alt, ...propsRest} = props;
32
14
  return (
33
- <>
34
- {renderedSourceNames.map((sourceName) => (
15
+ <ThemedComponent className={parentClassName}>
16
+ {({theme, className}) => (
35
17
  <img
36
- key={sourceName}
37
- src={sources[sourceName]}
18
+ src={sources[theme]}
38
19
  alt={alt}
39
- className={clsx(
40
- styles.themedImage,
41
- styles[`themedImage--${sourceName}`],
42
- className,
43
- )}
20
+ className={className}
44
21
  {...propsRest}
45
22
  />
46
- ))}
47
- </>
23
+ )}
24
+ </ThemedComponent>
48
25
  );
49
26
  }
@@ -0,0 +1,42 @@
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 {
11
+ ThemeClassNames,
12
+ UnlistedBannerTitle,
13
+ UnlistedBannerMessage,
14
+ UnlistedMetadata,
15
+ } from '@docusaurus/theme-common';
16
+ import Admonition from '@theme/Admonition';
17
+ import type {Props} from '@theme/Unlisted';
18
+
19
+ function UnlistedBanner({className}: Props) {
20
+ return (
21
+ <Admonition
22
+ type="caution"
23
+ title={<UnlistedBannerTitle />}
24
+ className={clsx(className, ThemeClassNames.common.unlistedBanner)}>
25
+ <UnlistedBannerMessage />
26
+ </Admonition>
27
+ );
28
+ }
29
+
30
+ export default function Unlisted(props: Props): JSX.Element | null {
31
+ return (
32
+ <>
33
+ {/*
34
+ Unlisted metadata declared here for simplicity.
35
+ Ensures we never forget to add the correct noindex metadata.
36
+ Also gives a central place for user to swizzle override default metadata.
37
+ */}
38
+ <UnlistedMetadata />
39
+ <UnlistedBanner {...props} />
40
+ </>
41
+ );
42
+ }
@@ -7,6 +7,7 @@
7
7
 
8
8
  import siteConfig from '@generated/docusaurus.config';
9
9
  import type * as PrismNamespace from 'prismjs';
10
+ import type {Optional} from 'utility-types';
10
11
 
11
12
  export default function prismIncludeLanguages(
12
13
  PrismObject: typeof PrismNamespace,
@@ -29,5 +30,5 @@ export default function prismIncludeLanguages(
29
30
  require(`prismjs/components/prism-${lang}`);
30
31
  });
31
32
 
32
- delete (globalThis as Global & {Prism?: typeof PrismNamespace}).Prism;
33
+ delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism;
33
34
  }