@docusaurus/theme-classic 2.4.1 → 3.0.0-beta.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 (174) hide show
  1. package/lib/getSwizzleConfig.js +107 -8
  2. package/lib/index.js +20 -6
  3. package/lib/nprogress.d.ts +1 -1
  4. package/lib/options.js +6 -2
  5. package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
  6. package/lib/theme/Admonition/Icon/Danger.js +17 -0
  7. package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
  8. package/lib/theme/Admonition/Icon/Info.js +17 -0
  9. package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
  10. package/lib/theme/Admonition/Icon/Note.js +17 -0
  11. package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
  12. package/lib/theme/Admonition/Icon/Tip.js +17 -0
  13. package/lib/theme/Admonition/Icon/Warning.d.ts +9 -0
  14. package/lib/theme/Admonition/Icon/Warning.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 +34 -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/Type/Warning.d.ts +9 -0
  29. package/lib/theme/Admonition/Type/Warning.js +32 -0
  30. package/lib/theme/Admonition/Types.d.ts +12 -0
  31. package/lib/theme/Admonition/Types.js +33 -0
  32. package/lib/theme/Admonition/index.d.ts +1 -1
  33. package/lib/theme/Admonition/index.js +12 -171
  34. package/lib/theme/BlogArchivePage/index.js +7 -2
  35. package/lib/theme/BlogLayout/index.js +1 -1
  36. package/lib/theme/BlogPostItem/Container/index.js +12 -3
  37. package/lib/theme/BlogPostItem/Header/Author/index.js +6 -1
  38. package/lib/theme/BlogPostPage/index.js +3 -1
  39. package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
  40. package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
  41. package/lib/theme/BlogTagsListPage/index.js +2 -1
  42. package/lib/theme/BlogTagsPostsPage/index.js +4 -2
  43. package/lib/theme/CodeBlock/Content/String.js +9 -2
  44. package/lib/theme/CodeBlock/CopyButton/index.js +0 -1
  45. package/lib/theme/DocBreadcrumbs/index.js +6 -2
  46. package/lib/theme/DocCard/index.js +8 -4
  47. package/lib/theme/DocItem/Layout/index.js +5 -0
  48. package/lib/theme/DocItem/index.js +1 -1
  49. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
  50. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
  51. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
  52. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
  53. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
  54. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +2 -2
  55. package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
  56. package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
  57. package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  58. package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
  59. package/lib/theme/DocRoot/index.js +31 -0
  60. package/lib/theme/DocSidebar/Desktop/index.d.ts +1 -1
  61. package/lib/theme/DocSidebar/Mobile/index.d.ts +1 -1
  62. package/lib/theme/DocSidebarItem/Category/index.js +24 -13
  63. package/lib/theme/DocSidebarItems/index.js +6 -4
  64. package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
  65. package/lib/theme/DocTagDocListPage/index.js +53 -39
  66. package/lib/theme/DocTagsListPage/index.d.ts +1 -1
  67. package/lib/theme/DocTagsListPage/index.js +26 -17
  68. package/lib/theme/DocVersionRoot/index.d.ts +10 -0
  69. package/lib/theme/DocVersionRoot/index.js +46 -0
  70. package/lib/theme/DocsRoot/index.d.ts +10 -0
  71. package/lib/theme/DocsRoot/index.js +18 -0
  72. package/lib/theme/EditThisPage/index.js +3 -6
  73. package/lib/theme/ErrorPageContent.js +3 -2
  74. package/lib/theme/MDXComponents/Code.js +2 -36
  75. package/lib/theme/MDXComponents/Details.js +1 -1
  76. package/lib/theme/MDXComponents/Pre.d.ts +2 -2
  77. package/lib/theme/MDXComponents/Pre.js +4 -11
  78. package/lib/theme/MDXComponents/Ul/index.js +4 -0
  79. package/lib/theme/MDXComponents/index.js +4 -3
  80. package/lib/theme/MDXPage/index.js +16 -4
  81. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
  82. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
  83. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
  84. package/lib/theme/NotFound/Content/index.d.ts +9 -0
  85. package/lib/theme/NotFound/Content/index.js +42 -0
  86. package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
  87. package/lib/theme/NotFound/index.js +25 -0
  88. package/lib/theme/SiteMetadata/index.js +30 -3
  89. package/lib/theme/TOCItems/Tree.js +3 -4
  90. package/lib/theme/Tabs/index.js +4 -2
  91. package/lib/theme/TagsListByLetter/index.js +4 -1
  92. package/lib/theme/ThemedImage/index.js +8 -24
  93. package/lib/theme/{MDXComponents/Head.d.ts → Unlisted/index.d.ts} +2 -2
  94. package/lib/theme/Unlisted/index.js +38 -0
  95. package/package.json +26 -26
  96. package/src/getSwizzleConfig.ts +116 -9
  97. package/src/index.ts +21 -6
  98. package/src/nprogress.ts +2 -1
  99. package/src/options.ts +7 -2
  100. package/src/theme/Admonition/Icon/Danger.tsx +20 -0
  101. package/src/theme/Admonition/Icon/Info.tsx +20 -0
  102. package/src/theme/Admonition/Icon/Note.tsx +20 -0
  103. package/src/theme/Admonition/Icon/Tip.tsx +20 -0
  104. package/src/theme/Admonition/Icon/Warning.tsx +20 -0
  105. package/src/theme/Admonition/Layout/index.tsx +57 -0
  106. package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  107. package/src/theme/Admonition/Type/Caution.tsx +39 -0
  108. package/src/theme/Admonition/Type/Danger.tsx +37 -0
  109. package/src/theme/Admonition/Type/Info.tsx +37 -0
  110. package/src/theme/Admonition/Type/Note.tsx +37 -0
  111. package/src/theme/Admonition/Type/Tip.tsx +37 -0
  112. package/src/theme/Admonition/Type/Warning.tsx +37 -0
  113. package/src/theme/Admonition/Types.tsx +38 -0
  114. package/src/theme/Admonition/index.tsx +13 -194
  115. package/src/theme/BlogArchivePage/index.tsx +7 -2
  116. package/src/theme/BlogLayout/index.tsx +1 -1
  117. package/src/theme/BlogPostItem/Container/index.tsx +12 -3
  118. package/src/theme/BlogPostItem/Header/Author/index.tsx +6 -1
  119. package/src/theme/BlogPostPage/index.tsx +3 -1
  120. package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
  121. package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
  122. package/src/theme/BlogTagsListPage/index.tsx +2 -1
  123. package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
  124. package/src/theme/CodeBlock/Content/String.tsx +11 -2
  125. package/src/theme/CodeBlock/CopyButton/index.tsx +0 -1
  126. package/src/theme/DocBreadcrumbs/index.tsx +6 -2
  127. package/src/theme/DocCard/index.tsx +11 -6
  128. package/src/theme/DocItem/Layout/index.tsx +5 -0
  129. package/src/theme/DocItem/index.tsx +1 -1
  130. package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
  131. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
  132. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +3 -3
  133. package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
  134. package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  135. package/src/theme/DocRoot/index.tsx +34 -0
  136. package/src/theme/DocSidebarItem/Category/index.tsx +25 -12
  137. package/src/theme/DocSidebarItems/index.tsx +6 -4
  138. package/src/theme/DocTagDocListPage/index.tsx +60 -39
  139. package/src/theme/DocTagsListPage/index.tsx +33 -17
  140. package/src/theme/DocVersionRoot/index.tsx +51 -0
  141. package/src/theme/DocsRoot/index.tsx +22 -0
  142. package/src/theme/EditThisPage/index.tsx +3 -6
  143. package/src/theme/ErrorPageContent.tsx +3 -2
  144. package/src/theme/MDXComponents/Code.tsx +2 -39
  145. package/src/theme/MDXComponents/Details.tsx +1 -2
  146. package/src/theme/MDXComponents/Pre.tsx +5 -13
  147. package/src/theme/MDXComponents/Ul/index.tsx +5 -1
  148. package/src/theme/MDXComponents/index.tsx +11 -10
  149. package/src/theme/MDXPage/index.tsx +16 -4
  150. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
  151. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
  152. package/src/theme/NotFound/Content/index.tsx +45 -0
  153. package/src/theme/NotFound/index.tsx +27 -0
  154. package/src/theme/SiteMetadata/index.tsx +36 -3
  155. package/src/theme/SkipToContent/index.tsx +0 -1
  156. package/src/theme/TOCItems/Tree.tsx +3 -4
  157. package/src/theme/Tabs/index.tsx +4 -2
  158. package/src/theme/TagsListByLetter/index.tsx +4 -2
  159. package/src/theme/ThemedImage/index.tsx +8 -31
  160. package/src/theme/Unlisted/index.tsx +42 -0
  161. package/src/theme/prism-include-languages.ts +2 -1
  162. package/src/theme-classic.d.ts +146 -21
  163. package/lib/theme/DocPage/index.js +0 -67
  164. package/lib/theme/MDXComponents/Head.js +0 -23
  165. package/lib/theme/NotFound.js +0 -52
  166. package/src/theme/DocPage/index.tsx +0 -71
  167. package/src/theme/MDXComponents/Head.tsx +0 -29
  168. package/src/theme/NotFound.tsx +0 -54
  169. /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  170. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  171. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
  172. /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  173. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  174. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
@@ -8,7 +8,7 @@ import React from 'react';
8
8
  import {translate} from '@docusaurus/Translate';
9
9
  import IconArrow from '@theme/Icon/Arrow';
10
10
  import styles from './styles.module.css';
11
- export default function DocPageLayoutSidebarExpandButton({toggleSidebar}) {
11
+ export default function DocRootLayoutSidebarExpandButton({toggleSidebar}) {
12
12
  return (
13
13
  <div
14
14
  className={styles.expandButton}
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="react" />
8
- import type { Props } from '@theme/DocPage/Layout/Sidebar';
9
- export default function DocPageLayoutSidebar({ sidebar, hiddenSidebarContainer, setHiddenSidebarContainer, }: Props): JSX.Element;
8
+ import type { Props } from '@theme/DocRoot/Layout/Sidebar';
9
+ export default function DocRootLayoutSidebar({ sidebar, hiddenSidebarContainer, setHiddenSidebarContainer, }: Props): JSX.Element;
@@ -10,7 +10,7 @@ import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
10
10
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
11
11
  import {useLocation} from '@docusaurus/router';
12
12
  import DocSidebar from '@theme/DocSidebar';
13
- import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
13
+ import ExpandButton from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
14
14
  import styles from './styles.module.css';
15
15
  // Reset sidebar state when sidebar changes
16
16
  // Use React key to unmount/remount the children
@@ -23,7 +23,7 @@ function ResetOnSidebarChange({children}) {
23
23
  </React.Fragment>
24
24
  );
25
25
  }
26
- export default function DocPageLayoutSidebar({
26
+ export default function DocRootLayoutSidebar({
27
27
  sidebar,
28
28
  hiddenSidebarContainer,
29
29
  setHiddenSidebarContainer,
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="react" />
8
- import type { Props } from '@theme/DocPage/Layout';
9
- export default function DocPageLayout({ children }: Props): JSX.Element;
8
+ import type { Props } from '@theme/DocRoot/Layout';
9
+ export default function DocRootLayout({ children }: Props): JSX.Element;
@@ -6,29 +6,28 @@
6
6
  */
7
7
  import React, {useState} from 'react';
8
8
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
9
- import Layout from '@theme/Layout';
10
9
  import BackToTopButton from '@theme/BackToTopButton';
11
- import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
12
- import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
10
+ import DocRootLayoutSidebar from '@theme/DocRoot/Layout/Sidebar';
11
+ import DocRootLayoutMain from '@theme/DocRoot/Layout/Main';
13
12
  import styles from './styles.module.css';
14
- export default function DocPageLayout({children}) {
13
+ export default function DocRootLayout({children}) {
15
14
  const sidebar = useDocsSidebar();
16
15
  const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
17
16
  return (
18
- <Layout wrapperClassName={styles.docsWrapper}>
17
+ <div className={styles.docsWrapper}>
19
18
  <BackToTopButton />
20
- <div className={styles.docPage}>
19
+ <div className={styles.docRoot}>
21
20
  {sidebar && (
22
- <DocPageLayoutSidebar
21
+ <DocRootLayoutSidebar
23
22
  sidebar={sidebar.items}
24
23
  hiddenSidebarContainer={hiddenSidebarContainer}
25
24
  setHiddenSidebarContainer={setHiddenSidebarContainer}
26
25
  />
27
26
  )}
28
- <DocPageLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
27
+ <DocRootLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
29
28
  {children}
30
- </DocPageLayoutMain>
29
+ </DocRootLayoutMain>
31
30
  </div>
32
- </Layout>
31
+ </div>
33
32
  );
34
33
  }
@@ -5,10 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docPage {
8
+ .docRoot {
9
9
  display: flex;
10
10
  width: 100%;
11
- flex: 1 0;
12
11
  }
13
12
 
14
13
  .docsWrapper {
@@ -6,5 +6,5 @@
6
6
  */
7
7
  /// <reference types="@docusaurus/plugin-content-docs" />
8
8
  /// <reference types="react" />
9
- import type { Props } from '@theme/DocPage';
10
- export default function DocPage(props: Props): JSX.Element;
9
+ import type { Props } from '@theme/DocRoot';
10
+ export default function DocRoot(props: Props): JSX.Element;
@@ -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
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {
11
+ DocsSidebarProvider,
12
+ useDocRootMetadata,
13
+ } from '@docusaurus/theme-common/internal';
14
+ import DocRootLayout from '@theme/DocRoot/Layout';
15
+ import NotFoundContent from '@theme/NotFound/Content';
16
+ export default function DocRoot(props) {
17
+ const currentDocRouteMetadata = useDocRootMetadata(props);
18
+ if (!currentDocRouteMetadata) {
19
+ // We only render the not found content to avoid a double layout
20
+ // see https://github.com/facebook/docusaurus/pull/7966#pullrequestreview-1077276692
21
+ return <NotFoundContent />;
22
+ }
23
+ const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
24
+ return (
25
+ <HtmlClassNameProvider className={clsx(ThemeClassNames.page.docsDocPage)}>
26
+ <DocsSidebarProvider name={sidebarName} items={sidebarItems}>
27
+ <DocRootLayout>{docElement}</DocRootLayout>
28
+ </DocsSidebarProvider>
29
+ </HtmlClassNameProvider>
30
+ );
31
+ }
@@ -6,6 +6,6 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import type { Props } from '@theme/DocSidebar/Desktop';
9
- declare function DocSidebarDesktop({ path, sidebar, onCollapse, isHidden }: Props): JSX.Element;
9
+ declare function DocSidebarDesktop({ path, sidebar, onCollapse, isHidden }: Props): React.JSX.Element;
10
10
  declare const _default: React.MemoExoticComponent<typeof DocSidebarDesktop>;
11
11
  export default _default;
@@ -6,6 +6,6 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import type { Props } from '@theme/DocSidebar/Mobile';
9
- declare function DocSidebarMobile(props: Props): JSX.Element;
9
+ declare function DocSidebarMobile(props: Props): React.JSX.Element;
10
10
  declare const _default: React.MemoExoticComponent<typeof DocSidebarMobile>;
11
11
  export default _default;
@@ -15,7 +15,7 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  import {
17
17
  isActiveSidebarItem,
18
- findFirstCategoryLink,
18
+ findFirstSidebarItemLink,
19
19
  useDocSidebarItemsExpandedState,
20
20
  isSamePath,
21
21
  } from '@docusaurus/theme-common/internal';
@@ -45,7 +45,7 @@ function useAutoExpandActiveCategory({isActive, collapsed, updateCollapsed}) {
45
45
  function useCategoryHrefWithSSRFallback(item) {
46
46
  const isBrowser = useIsBrowser();
47
47
  return useMemo(() => {
48
- if (item.href) {
48
+ if (item.href && !item.linkUnlisted) {
49
49
  return item.href;
50
50
  }
51
51
  // In these cases, it's not necessary to render a fallback
@@ -53,21 +53,31 @@ function useCategoryHrefWithSSRFallback(item) {
53
53
  if (isBrowser || !item.collapsible) {
54
54
  return undefined;
55
55
  }
56
- return findFirstCategoryLink(item);
56
+ return findFirstSidebarItemLink(item);
57
57
  }, [item, isBrowser]);
58
58
  }
59
- function CollapseButton({categoryLabel, onClick}) {
59
+ function CollapseButton({collapsed, categoryLabel, onClick}) {
60
60
  return (
61
61
  <button
62
- aria-label={translate(
63
- {
64
- id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
65
- message: "Toggle the collapsible sidebar category '{label}'",
66
- description:
67
- 'The ARIA label to toggle the collapsible sidebar category',
68
- },
69
- {label: categoryLabel},
70
- )}
62
+ aria-label={
63
+ collapsed
64
+ ? translate(
65
+ {
66
+ id: 'theme.DocSidebarItem.expandCategoryAriaLabel',
67
+ message: "Expand sidebar category '{label}'",
68
+ description: 'The ARIA label to expand the sidebar category',
69
+ },
70
+ {label: categoryLabel},
71
+ )
72
+ : translate(
73
+ {
74
+ id: 'theme.DocSidebarItem.collapseCategoryAriaLabel',
75
+ message: "Collapse sidebar category '{label}'",
76
+ description: 'The ARIA label to collapse the sidebar category',
77
+ },
78
+ {label: categoryLabel},
79
+ )
80
+ }
71
81
  type="button"
72
82
  className="clean-btn menu__caret"
73
83
  onClick={onClick}
@@ -162,6 +172,7 @@ export default function DocSidebarItemCategory({
162
172
  </Link>
163
173
  {href && collapsible && (
164
174
  <CollapseButton
175
+ collapsed={collapsed}
165
176
  categoryLabel={label}
166
177
  onClick={(e) => {
167
178
  e.preventDefault();
@@ -5,14 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, {memo} from 'react';
8
- import {DocSidebarItemsExpandedStateProvider} from '@docusaurus/theme-common/internal';
8
+ import {
9
+ DocSidebarItemsExpandedStateProvider,
10
+ useVisibleSidebarItems,
11
+ } from '@docusaurus/theme-common/internal';
9
12
  import DocSidebarItem from '@theme/DocSidebarItem';
10
- // TODO this item should probably not receive the "activePath" props
11
- // TODO this triggers whole sidebar re-renders on navigation
12
13
  function DocSidebarItems({items, ...props}) {
14
+ const visibleItems = useVisibleSidebarItems(items, props.activePath);
13
15
  return (
14
16
  <DocSidebarItemsExpandedStateProvider>
15
- {items.map((item, index) => (
17
+ {visibleItems.map((item, index) => (
16
18
  <DocSidebarItem key={index} item={item} index={index} {...props} />
17
19
  ))}
18
20
  </DocSidebarItemsExpandedStateProvider>
@@ -7,4 +7,4 @@
7
7
  /// <reference types="@docusaurus/plugin-content-docs" />
8
8
  /// <reference types="react" />
9
9
  import type { Props } from '@theme/DocTagDocListPage';
10
- export default function DocTagDocListPage({ tag }: Props): JSX.Element;
10
+ export default function DocTagDocListPage(props: Props): JSX.Element;
@@ -14,8 +14,9 @@ import {
14
14
  usePluralForm,
15
15
  } from '@docusaurus/theme-common';
16
16
  import Translate, {translate} from '@docusaurus/Translate';
17
- import Layout from '@theme/Layout';
18
17
  import SearchMetadata from '@theme/SearchMetadata';
18
+ import Unlisted from '@theme/Unlisted';
19
+ import Heading from '@theme/Heading';
19
20
  // Very simple pluralization: probably good enough for now
20
21
  function useNDocsTaggedPlural() {
21
22
  const {selectMessage} = usePluralForm();
@@ -33,57 +34,70 @@ function useNDocsTaggedPlural() {
33
34
  ),
34
35
  );
35
36
  }
37
+ function usePageTitle(props) {
38
+ const nDocsTaggedPlural = useNDocsTaggedPlural();
39
+ return translate(
40
+ {
41
+ id: 'theme.docs.tagDocListPageTitle',
42
+ description: 'The title of the page for a docs tag',
43
+ message: '{nDocsTagged} with "{tagName}"',
44
+ },
45
+ {nDocsTagged: nDocsTaggedPlural(props.tag.count), tagName: props.tag.label},
46
+ );
47
+ }
36
48
  function DocItem({doc}) {
37
49
  return (
38
50
  <article className="margin-vert--lg">
39
51
  <Link to={doc.permalink}>
40
- <h2>{doc.title}</h2>
52
+ <Heading as="h2">{doc.title}</Heading>
41
53
  </Link>
42
54
  {doc.description && <p>{doc.description}</p>}
43
55
  </article>
44
56
  );
45
57
  }
46
- export default function DocTagDocListPage({tag}) {
47
- const nDocsTaggedPlural = useNDocsTaggedPlural();
48
- const title = translate(
49
- {
50
- id: 'theme.docs.tagDocListPageTitle',
51
- description: 'The title of the page for a docs tag',
52
- message: '{nDocsTagged} with "{tagName}"',
53
- },
54
- {nDocsTagged: nDocsTaggedPlural(tag.count), tagName: tag.label},
55
- );
58
+ function DocTagDocListPageMetadata({title}) {
56
59
  return (
57
- <HtmlClassNameProvider
58
- className={clsx(
59
- ThemeClassNames.wrapper.docsPages,
60
- ThemeClassNames.page.docsTagDocListPage,
61
- )}>
60
+ <>
62
61
  <PageMetadata title={title} />
63
62
  <SearchMetadata tag="doc_tag_doc_list" />
64
- <Layout>
65
- <div className="container margin-vert--lg">
66
- <div className="row">
67
- <main className="col col--8 col--offset-2">
68
- <header className="margin-bottom--xl">
69
- <h1>{title}</h1>
70
- <Link href={tag.allTagsPath}>
71
- <Translate
72
- id="theme.tags.tagsPageLink"
73
- description="The label of the link targeting the tag list page">
74
- View All Tags
75
- </Translate>
76
- </Link>
77
- </header>
78
- <section className="margin-vert--lg">
79
- {tag.items.map((doc) => (
80
- <DocItem key={doc.id} doc={doc} />
81
- ))}
82
- </section>
83
- </main>
84
- </div>
63
+ </>
64
+ );
65
+ }
66
+ function DocTagDocListPageContent({tag, title}) {
67
+ return (
68
+ <HtmlClassNameProvider
69
+ className={clsx(ThemeClassNames.page.docsTagDocListPage)}>
70
+ <div className="container margin-vert--lg">
71
+ <div className="row">
72
+ <main className="col col--8 col--offset-2">
73
+ {tag.unlisted && <Unlisted />}
74
+ <header className="margin-bottom--xl">
75
+ <Heading as="h1">{title}</Heading>
76
+ <Link href={tag.allTagsPath}>
77
+ <Translate
78
+ id="theme.tags.tagsPageLink"
79
+ description="The label of the link targeting the tag list page">
80
+ View All Tags
81
+ </Translate>
82
+ </Link>
83
+ </header>
84
+ <section className="margin-vert--lg">
85
+ {tag.items.map((doc) => (
86
+ <DocItem key={doc.id} doc={doc} />
87
+ ))}
88
+ </section>
89
+ </main>
85
90
  </div>
86
- </Layout>
91
+ </div>
87
92
  </HtmlClassNameProvider>
88
93
  );
89
94
  }
95
+ export default function DocTagDocListPage(props) {
96
+ const title = usePageTitle(props);
97
+ return (
98
+ <>
99
+ <DocTagDocListPageMetadata {...props} title={title} />
100
+ <DocTagDocListPageContent {...props} title={title} />
101
+ </>
102
+ );
103
+ }
@@ -7,4 +7,4 @@
7
7
  /// <reference types="@docusaurus/plugin-content-docs" />
8
8
  /// <reference types="react" />
9
9
  import type { Props } from '@theme/DocTagsListPage';
10
- export default function DocTagsListPage({ tags }: Props): JSX.Element;
10
+ export default function DocTagsListPage(props: Props): JSX.Element;
@@ -12,29 +12,38 @@ import {
12
12
  ThemeClassNames,
13
13
  translateTagsPageTitle,
14
14
  } from '@docusaurus/theme-common';
15
- import Layout from '@theme/Layout';
16
15
  import TagsListByLetter from '@theme/TagsListByLetter';
17
16
  import SearchMetadata from '@theme/SearchMetadata';
18
- export default function DocTagsListPage({tags}) {
19
- const title = translateTagsPageTitle();
17
+ import Heading from '@theme/Heading';
18
+ function DocTagsListPageMetadata({title}) {
20
19
  return (
21
- <HtmlClassNameProvider
22
- className={clsx(
23
- ThemeClassNames.wrapper.docsPages,
24
- ThemeClassNames.page.docsTagsListPage,
25
- )}>
20
+ <>
26
21
  <PageMetadata title={title} />
27
22
  <SearchMetadata tag="doc_tags_list" />
28
- <Layout>
29
- <div className="container margin-vert--lg">
30
- <div className="row">
31
- <main className="col col--8 col--offset-2">
32
- <h1>{title}</h1>
33
- <TagsListByLetter tags={tags} />
34
- </main>
35
- </div>
23
+ </>
24
+ );
25
+ }
26
+ function DocTagsListPageContent({tags, title}) {
27
+ return (
28
+ <HtmlClassNameProvider
29
+ className={clsx(ThemeClassNames.page.docsTagsListPage)}>
30
+ <div className="container margin-vert--lg">
31
+ <div className="row">
32
+ <main className="col col--8 col--offset-2">
33
+ <Heading as="h1">{title}</Heading>
34
+ <TagsListByLetter tags={tags} />
35
+ </main>
36
36
  </div>
37
- </Layout>
37
+ </div>
38
38
  </HtmlClassNameProvider>
39
39
  );
40
40
  }
41
+ export default function DocTagsListPage(props) {
42
+ const title = translateTagsPageTitle();
43
+ return (
44
+ <>
45
+ <DocTagsListPageMetadata {...props} title={title} />
46
+ <DocTagsListPageContent {...props} title={title} />
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,10 @@
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
+ /// <reference types="@docusaurus/plugin-content-docs" />
8
+ /// <reference types="react" />
9
+ import type { Props } from '@theme/DocVersionRoot';
10
+ export default function DocVersionRoot(props: Props): JSX.Element;
@@ -0,0 +1,46 @@
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
+ import React from 'react';
8
+ import {HtmlClassNameProvider, PageMetadata} from '@docusaurus/theme-common';
9
+ import {
10
+ docVersionSearchTag,
11
+ DocsVersionProvider,
12
+ } from '@docusaurus/theme-common/internal';
13
+ import renderRoutes from '@docusaurus/renderRoutes';
14
+ import SearchMetadata from '@theme/SearchMetadata';
15
+ function DocVersionRootMetadata(props) {
16
+ const {version} = props;
17
+ return (
18
+ <>
19
+ <SearchMetadata
20
+ version={version.version}
21
+ tag={docVersionSearchTag(version.pluginId, version.version)}
22
+ />
23
+ <PageMetadata>
24
+ {version.noIndex && <meta name="robots" content="noindex, nofollow" />}
25
+ </PageMetadata>
26
+ </>
27
+ );
28
+ }
29
+ function DocVersionRootContent(props) {
30
+ const {version, route} = props;
31
+ return (
32
+ <HtmlClassNameProvider className={version.className}>
33
+ <DocsVersionProvider version={version}>
34
+ {renderRoutes(route.routes)}
35
+ </DocsVersionProvider>
36
+ </HtmlClassNameProvider>
37
+ );
38
+ }
39
+ export default function DocVersionRoot(props) {
40
+ return (
41
+ <>
42
+ <DocVersionRootMetadata {...props} />
43
+ <DocVersionRootContent {...props} />
44
+ </>
45
+ );
46
+ }
@@ -0,0 +1,10 @@
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
+ /// <reference types="@docusaurus/plugin-content-docs" />
8
+ /// <reference types="react" />
9
+ import type { Props } from '@theme/DocVersionRoot';
10
+ export default function DocsRoot(props: Props): JSX.Element;
@@ -0,0 +1,18 @@
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
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import {ThemeClassNames, HtmlClassNameProvider} from '@docusaurus/theme-common';
10
+ import renderRoutes from '@docusaurus/renderRoutes';
11
+ import Layout from '@theme/Layout';
12
+ export default function DocsRoot(props) {
13
+ return (
14
+ <HtmlClassNameProvider className={clsx(ThemeClassNames.wrapper.docsPages)}>
15
+ <Layout>{renderRoutes(props.route.routes)}</Layout>
16
+ </HtmlClassNameProvider>
17
+ );
18
+ }
@@ -7,20 +7,17 @@
7
7
  import React from 'react';
8
8
  import Translate from '@docusaurus/Translate';
9
9
  import {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import Link from '@docusaurus/Link';
10
11
  import IconEdit from '@theme/Icon/Edit';
11
12
  export default function EditThisPage({editUrl}) {
12
13
  return (
13
- <a
14
- href={editUrl}
15
- target="_blank"
16
- rel="noreferrer noopener"
17
- className={ThemeClassNames.common.editThisPage}>
14
+ <Link to={editUrl} className={ThemeClassNames.common.editThisPage}>
18
15
  <IconEdit />
19
16
  <Translate
20
17
  id="theme.common.editThisPage"
21
18
  description="The link label to edit the current page">
22
19
  Edit this page
23
20
  </Translate>
24
- </a>
21
+ </Link>
25
22
  );
26
23
  }
@@ -10,18 +10,19 @@ import {
10
10
  ErrorBoundaryError,
11
11
  ErrorBoundaryTryAgainButton,
12
12
  } from '@docusaurus/theme-common';
13
+ import Heading from '@theme/Heading';
13
14
  export default function ErrorPageContent({error, tryAgain}) {
14
15
  return (
15
16
  <main className="container margin-vert--xl">
16
17
  <div className="row">
17
18
  <div className="col col--6 col--offset-3">
18
- <h1 className="hero__title">
19
+ <Heading as="h1" className="hero__title">
19
20
  <Translate
20
21
  id="theme.ErrorPageContent.title"
21
22
  description="The title of the fallback page when the page crashed">
22
23
  This page crashed.
23
24
  </Translate>
24
- </h1>
25
+ </Heading>
25
26
  <div className="margin-vert--lg">
26
27
  <ErrorBoundaryTryAgainButton
27
28
  onClick={tryAgain}
@@ -4,45 +4,11 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, {isValidElement} from 'react';
7
+ import React from 'react';
8
8
  import CodeBlock from '@theme/CodeBlock';
9
9
  export default function MDXCode(props) {
10
- const inlineElements = [
11
- 'a',
12
- 'abbr',
13
- 'b',
14
- 'br',
15
- 'button',
16
- 'cite',
17
- 'code',
18
- 'del',
19
- 'dfn',
20
- 'em',
21
- 'i',
22
- 'img',
23
- 'input',
24
- 'ins',
25
- 'kbd',
26
- 'label',
27
- 'object',
28
- 'output',
29
- 'q',
30
- 'ruby',
31
- 's',
32
- 'small',
33
- 'span',
34
- 'strong',
35
- 'sub',
36
- 'sup',
37
- 'time',
38
- 'u',
39
- 'var',
40
- 'wbr',
41
- ];
42
10
  const shouldBeInline = React.Children.toArray(props.children).every(
43
- (el) =>
44
- (typeof el === 'string' && !el.includes('\n')) ||
45
- (isValidElement(el) && inlineElements.includes(el.props?.mdxType)),
11
+ (el) => typeof el === 'string' && !el.includes('\n'),
46
12
  );
47
13
  return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
48
14
  }
@@ -11,7 +11,7 @@ export default function MDXDetails(props) {
11
11
  // Split summary item from the rest to pass it as a separate prop to the
12
12
  // Details theme component
13
13
  const summary = items.find(
14
- (item) => React.isValidElement(item) && item.props?.mdxType === 'summary',
14
+ (item) => React.isValidElement(item) && item.type === 'summary',
15
15
  );
16
16
  const children = <>{items.filter((item) => item !== summary)}</>;
17
17
  return (
@@ -4,6 +4,6 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- /// <reference types="react" />
7
+ import { type ReactNode } from 'react';
8
8
  import type { Props } from '@theme/MDXComponents/Pre';
9
- export default function MDXPre(props: Props): JSX.Element;
9
+ export default function MDXPre(props: Props): ReactNode | undefined;