@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,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
+ }
@@ -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,7 +53,7 @@ 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
59
  function CollapseButton({categoryLabel, onClick}) {
@@ -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}
@@ -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/MDXComponents/Head';
9
- export default function MDXHead(props: Props): JSX.Element;
8
+ import type { Props } from '@theme/Icon/Copy';
9
+ export default function IconCopy(props: Props): JSX.Element;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export default function IconCopy(props) {
9
+ return (
10
+ <svg viewBox="0 0 24 24" {...props}>
11
+ <path
12
+ fill="currentColor"
13
+ 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"
14
+ />
15
+ </svg>
16
+ );
17
+ }
@@ -0,0 +1,9 @@
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="react" />
8
+ import type { Props } from '@theme/Icon/Success';
9
+ export default function IconSuccess(props: Props): JSX.Element;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export default function IconSuccess(props) {
9
+ return (
10
+ <svg viewBox="0 0 24 24" {...props}>
11
+ <path
12
+ fill="currentColor"
13
+ d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"
14
+ />
15
+ </svg>
16
+ );
17
+ }
@@ -0,0 +1,9 @@
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="react" />
8
+ import type { Props } from '@theme/Icon/WordWrap';
9
+ export default function IconWordWrap(props: Props): JSX.Element;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export default function IconWordWrap(props) {
9
+ return (
10
+ <svg viewBox="0 0 24 24" {...props}>
11
+ <path
12
+ fill="currentColor"
13
+ 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"
14
+ />
15
+ </svg>
16
+ );
17
+ }
@@ -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;
@@ -4,16 +4,9 @@
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';
8
- import CodeBlock from '@theme/CodeBlock';
7
+ import React from 'react';
9
8
  export default function MDXPre(props) {
10
- return (
11
- <CodeBlock
12
- // If this pre is created by a ``` fenced codeblock, unwrap the children
13
- {...(isValidElement(props.children) &&
14
- props.children.props?.originalType === 'code'
15
- ? props.children.props
16
- : {...props})}
17
- />
18
- );
9
+ // With MDX 2, this element is only used for fenced code blocks
10
+ // It always receives a MDXComponents/Code as children
11
+ return <>{props.children}</>;
19
12
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import MDXHead from '@theme/MDXComponents/Head';
8
+ import Head from '@docusaurus/Head';
9
9
  import MDXCode from '@theme/MDXComponents/Code';
10
10
  import MDXA from '@theme/MDXComponents/A';
11
11
  import MDXPre from '@theme/MDXComponents/Pre';
@@ -16,11 +16,11 @@ import MDXImg from '@theme/MDXComponents/Img';
16
16
  import Admonition from '@theme/Admonition';
17
17
  import Mermaid from '@theme/Mermaid';
18
18
  const MDXComponents = {
19
- head: MDXHead,
19
+ Head,
20
+ Details: MDXDetails,
20
21
  code: MDXCode,
21
22
  a: MDXA,
22
23
  pre: MDXPre,
23
- details: MDXDetails,
24
24
  ul: MDXUl,
25
25
  img: MDXImg,
26
26
  h1: (props) => <MDXHeading as="h1" {...props} />,
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
+ // @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
8
9
  import {MDXProvider} from '@mdx-js/react';
9
10
  import MDXComponents from '@theme/MDXComponents';
10
11
  export default function MDXContent({children}) {