@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
@@ -7,32 +7,31 @@
7
7
 
8
8
  import React, {useState} from 'react';
9
9
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
10
- import Layout from '@theme/Layout';
11
10
  import BackToTopButton from '@theme/BackToTopButton';
12
- import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
13
- import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
14
- import type {Props} from '@theme/DocPage/Layout';
11
+ import DocRootLayoutSidebar from '@theme/DocRoot/Layout/Sidebar';
12
+ import DocRootLayoutMain from '@theme/DocRoot/Layout/Main';
13
+ import type {Props} from '@theme/DocRoot/Layout';
15
14
 
16
15
  import styles from './styles.module.css';
17
16
 
18
- export default function DocPageLayout({children}: Props): JSX.Element {
17
+ export default function DocRootLayout({children}: Props): JSX.Element {
19
18
  const sidebar = useDocsSidebar();
20
19
  const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
21
20
  return (
22
- <Layout wrapperClassName={styles.docsWrapper}>
21
+ <div className={styles.docsWrapper}>
23
22
  <BackToTopButton />
24
- <div className={styles.docPage}>
23
+ <div className={styles.docRoot}>
25
24
  {sidebar && (
26
- <DocPageLayoutSidebar
25
+ <DocRootLayoutSidebar
27
26
  sidebar={sidebar.items}
28
27
  hiddenSidebarContainer={hiddenSidebarContainer}
29
28
  setHiddenSidebarContainer={setHiddenSidebarContainer}
30
29
  />
31
30
  )}
32
- <DocPageLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
31
+ <DocRootLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
33
32
  {children}
34
- </DocPageLayoutMain>
33
+ </DocRootLayoutMain>
35
34
  </div>
36
- </Layout>
35
+ </div>
37
36
  );
38
37
  }
@@ -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 {
@@ -0,0 +1,34 @@
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 {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {
12
+ DocsSidebarProvider,
13
+ useDocRootMetadata,
14
+ } from '@docusaurus/theme-common/internal';
15
+ import DocRootLayout from '@theme/DocRoot/Layout';
16
+ import NotFoundContent from '@theme/NotFound/Content';
17
+ import type {Props} from '@theme/DocRoot';
18
+
19
+ export default function DocRoot(props: Props): JSX.Element {
20
+ const currentDocRouteMetadata = useDocRootMetadata(props);
21
+ if (!currentDocRouteMetadata) {
22
+ // We only render the not found content to avoid a double layout
23
+ // see https://github.com/facebook/docusaurus/pull/7966#pullrequestreview-1077276692
24
+ return <NotFoundContent />;
25
+ }
26
+ const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
27
+ return (
28
+ <HtmlClassNameProvider className={clsx(ThemeClassNames.page.docsDocPage)}>
29
+ <DocsSidebarProvider name={sidebarName} items={sidebarItems}>
30
+ <DocRootLayout>{docElement}</DocRootLayout>
31
+ </DocsSidebarProvider>
32
+ </HtmlClassNameProvider>
33
+ );
34
+ }
@@ -16,7 +16,7 @@ import {
16
16
  } from '@docusaurus/theme-common';
17
17
  import {
18
18
  isActiveSidebarItem,
19
- findFirstCategoryLink,
19
+ findFirstSidebarItemLink,
20
20
  useDocSidebarItemsExpandedState,
21
21
  isSamePath,
22
22
  } from '@docusaurus/theme-common/internal';
@@ -59,7 +59,7 @@ function useCategoryHrefWithSSRFallback(
59
59
  ): string | undefined {
60
60
  const isBrowser = useIsBrowser();
61
61
  return useMemo(() => {
62
- if (item.href) {
62
+ if (item.href && !item.linkUnlisted) {
63
63
  return item.href;
64
64
  }
65
65
  // In these cases, it's not necessary to render a fallback
@@ -67,28 +67,40 @@ function useCategoryHrefWithSSRFallback(
67
67
  if (isBrowser || !item.collapsible) {
68
68
  return undefined;
69
69
  }
70
- return findFirstCategoryLink(item);
70
+ return findFirstSidebarItemLink(item);
71
71
  }, [item, isBrowser]);
72
72
  }
73
73
 
74
74
  function CollapseButton({
75
+ collapsed,
75
76
  categoryLabel,
76
77
  onClick,
77
78
  }: {
79
+ collapsed: boolean;
78
80
  categoryLabel: string;
79
81
  onClick: ComponentProps<'button'>['onClick'];
80
82
  }) {
81
83
  return (
82
84
  <button
83
- aria-label={translate(
84
- {
85
- id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
86
- message: "Toggle the collapsible sidebar category '{label}'",
87
- description:
88
- 'The ARIA label to toggle the collapsible sidebar category',
89
- },
90
- {label: categoryLabel},
91
- )}
85
+ aria-label={
86
+ collapsed
87
+ ? translate(
88
+ {
89
+ id: 'theme.DocSidebarItem.expandCategoryAriaLabel',
90
+ message: "Expand sidebar category '{label}'",
91
+ description: 'The ARIA label to expand the sidebar category',
92
+ },
93
+ {label: categoryLabel},
94
+ )
95
+ : translate(
96
+ {
97
+ id: 'theme.DocSidebarItem.collapseCategoryAriaLabel',
98
+ message: "Collapse sidebar category '{label}'",
99
+ description: 'The ARIA label to collapse the sidebar category',
100
+ },
101
+ {label: categoryLabel},
102
+ )
103
+ }
92
104
  type="button"
93
105
  className="clean-btn menu__caret"
94
106
  onClick={onClick}
@@ -188,6 +200,7 @@ export default function DocSidebarItemCategory({
188
200
  </Link>
189
201
  {href && collapsible && (
190
202
  <CollapseButton
203
+ collapsed={collapsed}
191
204
  categoryLabel={label}
192
205
  onClick={(e) => {
193
206
  e.preventDefault();
@@ -6,17 +6,19 @@
6
6
  */
7
7
 
8
8
  import React, {memo} from 'react';
9
- import {DocSidebarItemsExpandedStateProvider} from '@docusaurus/theme-common/internal';
9
+ import {
10
+ DocSidebarItemsExpandedStateProvider,
11
+ useVisibleSidebarItems,
12
+ } from '@docusaurus/theme-common/internal';
10
13
  import DocSidebarItem from '@theme/DocSidebarItem';
11
14
 
12
15
  import type {Props} from '@theme/DocSidebarItems';
13
16
 
14
- // TODO this item should probably not receive the "activePath" props
15
- // TODO this triggers whole sidebar re-renders on navigation
16
17
  function DocSidebarItems({items, ...props}: Props): JSX.Element {
18
+ const visibleItems = useVisibleSidebarItems(items, props.activePath);
17
19
  return (
18
20
  <DocSidebarItemsExpandedStateProvider>
19
- {items.map((item, index) => (
21
+ {visibleItems.map((item, index) => (
20
22
  <DocSidebarItem key={index} item={item} index={index} {...props} />
21
23
  ))}
22
24
  </DocSidebarItemsExpandedStateProvider>
@@ -15,9 +15,10 @@ import {
15
15
  usePluralForm,
16
16
  } from '@docusaurus/theme-common';
17
17
  import Translate, {translate} from '@docusaurus/Translate';
18
- import Layout from '@theme/Layout';
19
18
  import SearchMetadata from '@theme/SearchMetadata';
20
19
  import type {Props} from '@theme/DocTagDocListPage';
20
+ import Unlisted from '@theme/Unlisted';
21
+ import Heading from '@theme/Heading';
21
22
 
22
23
  // Very simple pluralization: probably good enough for now
23
24
  function useNDocsTaggedPlural() {
@@ -37,59 +38,79 @@ function useNDocsTaggedPlural() {
37
38
  );
38
39
  }
39
40
 
41
+ function usePageTitle(props: Props): string {
42
+ const nDocsTaggedPlural = useNDocsTaggedPlural();
43
+ return translate(
44
+ {
45
+ id: 'theme.docs.tagDocListPageTitle',
46
+ description: 'The title of the page for a docs tag',
47
+ message: '{nDocsTagged} with "{tagName}"',
48
+ },
49
+ {nDocsTagged: nDocsTaggedPlural(props.tag.count), tagName: props.tag.label},
50
+ );
51
+ }
52
+
40
53
  function DocItem({doc}: {doc: Props['tag']['items'][number]}): JSX.Element {
41
54
  return (
42
55
  <article className="margin-vert--lg">
43
56
  <Link to={doc.permalink}>
44
- <h2>{doc.title}</h2>
57
+ <Heading as="h2">{doc.title}</Heading>
45
58
  </Link>
46
59
  {doc.description && <p>{doc.description}</p>}
47
60
  </article>
48
61
  );
49
62
  }
50
63
 
51
- export default function DocTagDocListPage({tag}: Props): JSX.Element {
52
- const nDocsTaggedPlural = useNDocsTaggedPlural();
53
- const title = translate(
54
- {
55
- id: 'theme.docs.tagDocListPageTitle',
56
- description: 'The title of the page for a docs tag',
57
- message: '{nDocsTagged} with "{tagName}"',
58
- },
59
- {nDocsTagged: nDocsTaggedPlural(tag.count), tagName: tag.label},
64
+ function DocTagDocListPageMetadata({
65
+ title,
66
+ }: Props & {title: string}): JSX.Element {
67
+ return (
68
+ <>
69
+ <PageMetadata title={title} />
70
+ <SearchMetadata tag="doc_tag_doc_list" />
71
+ </>
60
72
  );
73
+ }
61
74
 
75
+ function DocTagDocListPageContent({
76
+ tag,
77
+ title,
78
+ }: Props & {title: string}): JSX.Element {
62
79
  return (
63
80
  <HtmlClassNameProvider
64
- className={clsx(
65
- ThemeClassNames.wrapper.docsPages,
66
- ThemeClassNames.page.docsTagDocListPage,
67
- )}>
68
- <PageMetadata title={title} />
69
- <SearchMetadata tag="doc_tag_doc_list" />
70
- <Layout>
71
- <div className="container margin-vert--lg">
72
- <div className="row">
73
- <main className="col col--8 col--offset-2">
74
- <header className="margin-bottom--xl">
75
- <h1>{title}</h1>
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>
90
- </div>
81
+ className={clsx(ThemeClassNames.page.docsTagDocListPage)}>
82
+ <div className="container margin-vert--lg">
83
+ <div className="row">
84
+ <main className="col col--8 col--offset-2">
85
+ {tag.unlisted && <Unlisted />}
86
+ <header className="margin-bottom--xl">
87
+ <Heading as="h1">{title}</Heading>
88
+ <Link href={tag.allTagsPath}>
89
+ <Translate
90
+ id="theme.tags.tagsPageLink"
91
+ description="The label of the link targeting the tag list page">
92
+ View All Tags
93
+ </Translate>
94
+ </Link>
95
+ </header>
96
+ <section className="margin-vert--lg">
97
+ {tag.items.map((doc) => (
98
+ <DocItem key={doc.id} doc={doc} />
99
+ ))}
100
+ </section>
101
+ </main>
91
102
  </div>
92
- </Layout>
103
+ </div>
93
104
  </HtmlClassNameProvider>
94
105
  );
95
106
  }
107
+
108
+ export default function DocTagDocListPage(props: Props): JSX.Element {
109
+ const title = usePageTitle(props);
110
+ return (
111
+ <>
112
+ <DocTagDocListPageMetadata {...props} title={title} />
113
+ <DocTagDocListPageContent {...props} title={title} />
114
+ </>
115
+ );
116
+ }
@@ -13,31 +13,47 @@ import {
13
13
  ThemeClassNames,
14
14
  translateTagsPageTitle,
15
15
  } from '@docusaurus/theme-common';
16
- import Layout from '@theme/Layout';
17
16
  import TagsListByLetter from '@theme/TagsListByLetter';
18
17
  import SearchMetadata from '@theme/SearchMetadata';
19
18
  import type {Props} from '@theme/DocTagsListPage';
19
+ import Heading from '@theme/Heading';
20
20
 
21
- export default function DocTagsListPage({tags}: Props): JSX.Element {
22
- const title = translateTagsPageTitle();
21
+ function DocTagsListPageMetadata({
22
+ title,
23
+ }: Props & {title: string}): JSX.Element {
23
24
  return (
24
- <HtmlClassNameProvider
25
- className={clsx(
26
- ThemeClassNames.wrapper.docsPages,
27
- ThemeClassNames.page.docsTagsListPage,
28
- )}>
25
+ <>
29
26
  <PageMetadata title={title} />
30
27
  <SearchMetadata tag="doc_tags_list" />
31
- <Layout>
32
- <div className="container margin-vert--lg">
33
- <div className="row">
34
- <main className="col col--8 col--offset-2">
35
- <h1>{title}</h1>
36
- <TagsListByLetter tags={tags} />
37
- </main>
38
- </div>
28
+ </>
29
+ );
30
+ }
31
+
32
+ function DocTagsListPageContent({
33
+ tags,
34
+ title,
35
+ }: Props & {title: string}): JSX.Element {
36
+ return (
37
+ <HtmlClassNameProvider
38
+ className={clsx(ThemeClassNames.page.docsTagsListPage)}>
39
+ <div className="container margin-vert--lg">
40
+ <div className="row">
41
+ <main className="col col--8 col--offset-2">
42
+ <Heading as="h1">{title}</Heading>
43
+ <TagsListByLetter tags={tags} />
44
+ </main>
39
45
  </div>
40
- </Layout>
46
+ </div>
41
47
  </HtmlClassNameProvider>
42
48
  );
43
49
  }
50
+
51
+ export default function DocTagsListPage(props: Props): JSX.Element {
52
+ const title = translateTagsPageTitle();
53
+ return (
54
+ <>
55
+ <DocTagsListPageMetadata {...props} title={title} />
56
+ <DocTagsListPageContent {...props} title={title} />
57
+ </>
58
+ );
59
+ }
@@ -0,0 +1,51 @@
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 {HtmlClassNameProvider, PageMetadata} from '@docusaurus/theme-common';
10
+ import {
11
+ docVersionSearchTag,
12
+ DocsVersionProvider,
13
+ } from '@docusaurus/theme-common/internal';
14
+ import renderRoutes from '@docusaurus/renderRoutes';
15
+ import SearchMetadata from '@theme/SearchMetadata';
16
+
17
+ import type {Props} from '@theme/DocVersionRoot';
18
+
19
+ function DocVersionRootMetadata(props: Props): JSX.Element {
20
+ const {version} = props;
21
+ return (
22
+ <>
23
+ <SearchMetadata
24
+ version={version.version}
25
+ tag={docVersionSearchTag(version.pluginId, version.version)}
26
+ />
27
+ <PageMetadata>
28
+ {version.noIndex && <meta name="robots" content="noindex, nofollow" />}
29
+ </PageMetadata>
30
+ </>
31
+ );
32
+ }
33
+
34
+ function DocVersionRootContent(props: Props): JSX.Element {
35
+ const {version, route} = props;
36
+ return (
37
+ <HtmlClassNameProvider className={version.className}>
38
+ <DocsVersionProvider version={version}>
39
+ {renderRoutes(route.routes!)}
40
+ </DocsVersionProvider>
41
+ </HtmlClassNameProvider>
42
+ );
43
+ }
44
+ export default function DocVersionRoot(props: Props): JSX.Element {
45
+ return (
46
+ <>
47
+ <DocVersionRootMetadata {...props} />
48
+ <DocVersionRootContent {...props} />
49
+ </>
50
+ );
51
+ }
@@ -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}
@@ -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
  }
@@ -11,7 +11,11 @@ import type {Props} from '@theme/MDXComponents/Ul';
11
11
 
12
12
  import styles from './styles.module.css';
13
13
 
14
- function transformUlClassName(className?: string): string {
14
+ function transformUlClassName(className?: string): string | undefined {
15
+ // Fix https://github.com/facebook/docusaurus/issues/9098
16
+ if (typeof className === 'undefined') {
17
+ return undefined;
18
+ }
15
19
  return clsx(
16
20
  className,
17
21
  // This class is set globally by GitHub/MDX. We keep the global class, and
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React from 'react';
9
- import MDXHead from '@theme/MDXComponents/Head';
8
+ import React, {type ComponentProps} from 'react';
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,19 +20,20 @@ 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, // For MD mode support, see https://github.com/facebook/docusaurus/issues/9092#issuecomment-1602902274
25
+ Details: MDXDetails,
24
26
  code: MDXCode,
25
27
  a: MDXA,
26
28
  pre: MDXPre,
27
- details: MDXDetails,
28
29
  ul: MDXUl,
29
30
  img: MDXImg,
30
- h1: (props) => <MDXHeading as="h1" {...props} />,
31
- h2: (props) => <MDXHeading as="h2" {...props} />,
32
- h3: (props) => <MDXHeading as="h3" {...props} />,
33
- h4: (props) => <MDXHeading as="h4" {...props} />,
34
- h5: (props) => <MDXHeading as="h5" {...props} />,
35
- h6: (props) => <MDXHeading as="h6" {...props} />,
31
+ h1: (props: ComponentProps<'h1'>) => <MDXHeading as="h1" {...props} />,
32
+ h2: (props: ComponentProps<'h2'>) => <MDXHeading as="h2" {...props} />,
33
+ h3: (props: ComponentProps<'h3'>) => <MDXHeading as="h3" {...props} />,
34
+ h4: (props: ComponentProps<'h4'>) => <MDXHeading as="h4" {...props} />,
35
+ h5: (props: ComponentProps<'h5'>) => <MDXHeading as="h5" {...props} />,
36
+ h6: (props: ComponentProps<'h6'>) => <MDXHeading as="h6" {...props} />,
36
37
  admonition: Admonition,
37
38
  mermaid: Mermaid,
38
39
  };