@docusaurus/theme-classic 2.0.0-beta.21 → 2.0.0-beta.22

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 (240) hide show
  1. package/lib/getSwizzleConfig.js +5 -5
  2. package/lib/index.js +4 -2
  3. package/lib/theme/Admonition/index.d.ts +1 -1
  4. package/lib/theme/Admonition/index.js +139 -57
  5. package/lib/{admonitions.css → theme/Admonition/styles.module.css} +14 -15
  6. package/lib/theme/AnnouncementBar/index.js +3 -2
  7. package/lib/theme/BackToTopButton/index.js +2 -1
  8. package/lib/theme/BlogListPage/index.js +2 -11
  9. package/lib/theme/BlogPostItem/Container/index.d.ts +9 -0
  10. package/lib/theme/BlogPostItem/Container/index.js +26 -0
  11. package/lib/theme/BlogPostItem/Content/index.d.ts +9 -0
  12. package/lib/theme/BlogPostItem/Content/index.js +23 -0
  13. package/lib/theme/BlogPostItem/Footer/ReadMoreLink/index.d.ts +9 -0
  14. package/lib/theme/BlogPostItem/Footer/ReadMoreLink/index.js +38 -0
  15. package/lib/theme/BlogPostItem/Footer/index.d.ts +8 -0
  16. package/lib/theme/BlogPostItem/Footer/index.js +52 -0
  17. package/lib/theme/BlogPostItem/Footer/styles.module.css +10 -0
  18. package/lib/theme/BlogPostItem/Header/Author/index.d.ts +9 -0
  19. package/lib/theme/{BlogPostAuthor → BlogPostItem/Header/Author}/index.js +3 -2
  20. package/lib/theme/BlogPostItem/Header/Authors/index.d.ts +9 -0
  21. package/{src/theme/BlogPostAuthors/index.tsx → lib/theme/BlogPostItem/Header/Authors/index.js} +9 -10
  22. package/lib/theme/{BlogPostAuthors → BlogPostItem/Header/Authors}/styles.module.css +0 -0
  23. package/lib/theme/{BlogPostAuthors → BlogPostItem/Header/Info}/index.d.ts +2 -2
  24. package/lib/theme/BlogPostItem/Header/Info/index.js +60 -0
  25. package/lib/theme/BlogPostItem/Header/Info/styles.module.css +10 -0
  26. package/lib/theme/BlogPostItem/Header/Title/index.d.ts +9 -0
  27. package/lib/theme/BlogPostItem/Header/Title/index.js +27 -0
  28. package/{src/theme/BlogPostItem → lib/theme/BlogPostItem/Header/Title}/styles.module.css +2 -10
  29. package/lib/theme/BlogPostItem/Header/index.d.ts +8 -0
  30. package/lib/theme/BlogPostItem/Header/index.js +19 -0
  31. package/lib/theme/BlogPostItem/index.d.ts +1 -1
  32. package/lib/theme/BlogPostItem/index.js +16 -142
  33. package/lib/theme/BlogPostItems/index.d.ts +9 -0
  34. package/lib/theme/BlogPostItems/index.js +27 -0
  35. package/lib/theme/BlogPostPage/Metadata/index.d.ts +8 -0
  36. package/lib/theme/BlogPostPage/Metadata/index.js +41 -0
  37. package/lib/theme/BlogPostPage/index.js +21 -60
  38. package/lib/theme/BlogTagsListPage/index.js +1 -1
  39. package/lib/theme/BlogTagsPostsPage/index.d.ts +1 -1
  40. package/lib/theme/BlogTagsPostsPage/index.js +36 -30
  41. package/lib/theme/CodeBlock/Container/index.js +2 -5
  42. package/lib/theme/CodeBlock/Content/String.js +2 -3
  43. package/lib/theme/CodeBlock/CopyButton/index.js +1 -0
  44. package/lib/theme/CodeBlock/Line/styles.module.css +7 -7
  45. package/lib/theme/ColorModeToggle/index.js +2 -2
  46. package/lib/theme/DocBreadcrumbs/index.js +3 -3
  47. package/lib/theme/DocCard/index.js +4 -1
  48. package/lib/theme/DocCardList/index.js +2 -2
  49. package/lib/theme/DocItem/Content/index.d.ts +9 -0
  50. package/lib/theme/DocItem/Content/index.js +44 -0
  51. package/lib/theme/DocItem/Footer/index.d.ts +8 -0
  52. package/lib/theme/{DocItemFooter → DocItem/Footer}/index.js +3 -3
  53. package/lib/theme/{DocItemFooter → DocItem/Footer}/styles.module.css +0 -0
  54. package/lib/theme/{BlogPostAuthor → DocItem/Layout}/index.d.ts +2 -2
  55. package/lib/theme/DocItem/Layout/index.js +59 -0
  56. package/lib/theme/DocItem/Layout/styles.module.css +17 -0
  57. package/lib/theme/DocItem/Metadata/index.d.ts +8 -0
  58. package/lib/theme/DocItem/Metadata/index.js +20 -0
  59. package/lib/theme/{DocItemFooter → DocItem/Paginator}/index.d.ts +5 -3
  60. package/lib/theme/DocItem/Paginator/index.js +17 -0
  61. package/lib/theme/DocItem/TOC/Desktop/index.d.ts +8 -0
  62. package/lib/theme/DocItem/TOC/Desktop/index.js +21 -0
  63. package/lib/theme/DocItem/TOC/Mobile/index.d.ts +8 -0
  64. package/lib/theme/DocItem/TOC/Mobile/index.js +23 -0
  65. package/lib/theme/DocItem/{styles.module.css → TOC/Mobile/styles.module.css} +0 -9
  66. package/lib/theme/DocItem/index.js +13 -106
  67. package/lib/theme/DocPage/Layout/Main/index.js +1 -1
  68. package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +1 -1
  69. package/lib/theme/DocPage/Layout/Sidebar/index.js +2 -1
  70. package/lib/theme/DocPage/Layout/index.js +1 -1
  71. package/lib/theme/DocPage/index.js +2 -3
  72. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.js +1 -1
  73. package/lib/theme/DocSidebar/Desktop/Content/index.js +2 -2
  74. package/lib/theme/DocSidebar/Mobile/index.js +1 -1
  75. package/lib/theme/DocSidebarItem/Category/index.js +6 -4
  76. package/lib/theme/DocSidebarItem/Link/index.js +3 -2
  77. package/lib/theme/DocSidebarItems/index.js +1 -1
  78. package/lib/theme/DocVersionBadge/index.js +2 -1
  79. package/lib/theme/DocVersionBanner/index.js +2 -2
  80. package/lib/theme/EditThisPage/index.js +1 -1
  81. package/lib/theme/Footer/LinkItem/index.js +1 -1
  82. package/lib/theme/Footer/Logo/index.js +7 -2
  83. package/lib/theme/{IconArrow → Icon/Arrow}/index.d.ts +1 -1
  84. package/lib/theme/{IconArrow → Icon/Arrow}/index.js +0 -0
  85. package/lib/theme/{IconClose → Icon/Close}/index.d.ts +1 -1
  86. package/lib/theme/{IconClose → Icon/Close}/index.js +0 -0
  87. package/lib/theme/{IconDarkMode → Icon/DarkMode}/index.d.ts +1 -1
  88. package/lib/theme/{IconDarkMode → Icon/DarkMode}/index.js +0 -0
  89. package/lib/theme/{IconEdit → Icon/Edit}/index.d.ts +1 -1
  90. package/lib/theme/{IconEdit → Icon/Edit}/index.js +0 -0
  91. package/lib/theme/{IconEdit → Icon/Edit}/styles.module.css +0 -0
  92. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/index.d.ts +1 -1
  93. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/index.js +0 -0
  94. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/styles.module.css +0 -0
  95. package/lib/theme/{IconHome → Icon/Home}/index.d.ts +1 -1
  96. package/lib/theme/{IconHome → Icon/Home}/index.js +0 -0
  97. package/lib/theme/{IconLanguage → Icon/Language}/index.d.ts +1 -1
  98. package/lib/theme/{IconLanguage → Icon/Language}/index.js +0 -0
  99. package/lib/theme/{IconLightMode → Icon/LightMode}/index.d.ts +1 -1
  100. package/lib/theme/{IconLightMode → Icon/LightMode}/index.js +0 -0
  101. package/lib/theme/{IconMenu → Icon/Menu}/index.d.ts +1 -1
  102. package/lib/theme/{IconMenu → Icon/Menu}/index.js +0 -0
  103. package/lib/theme/Layout/Provider/index.d.ts +9 -0
  104. package/lib/theme/Layout/Provider/index.js +29 -0
  105. package/lib/theme/Layout/index.d.ts +0 -1
  106. package/lib/theme/Layout/index.js +12 -10
  107. package/{src/theme/Layout/styles.css → lib/theme/Layout/styles.module.css} +10 -12
  108. package/lib/theme/Logo/index.js +35 -17
  109. package/lib/theme/MDXComponents/Code.js +1 -1
  110. package/lib/theme/MDXComponents/index.js +2 -0
  111. package/lib/theme/MDXPage/index.js +6 -4
  112. package/lib/theme/Navbar/Content/index.js +2 -2
  113. package/lib/theme/Navbar/Layout/index.js +2 -2
  114. package/lib/theme/Navbar/MobileSidebar/Header/index.js +2 -2
  115. package/lib/theme/Navbar/MobileSidebar/Layout/index.js +1 -1
  116. package/lib/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +2 -1
  117. package/lib/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +2 -1
  118. package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +2 -2
  119. package/lib/theme/Navbar/MobileSidebar/index.js +1 -1
  120. package/lib/theme/NavbarItem/DocNavbarItem.js +1 -1
  121. package/lib/theme/NavbarItem/DocSidebarNavbarItem.js +1 -1
  122. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -4
  123. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +1 -1
  124. package/lib/theme/NavbarItem/DropdownNavbarItem.js +2 -3
  125. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -2
  126. package/lib/theme/NavbarItem/NavbarNavLink.js +1 -1
  127. package/lib/theme/SiteMetadata/index.js +2 -3
  128. package/lib/theme/SkipToContent/index.js +1 -1
  129. package/lib/theme/TOCItems/index.js +2 -2
  130. package/lib/theme/Tabs/index.js +2 -2
  131. package/lib/validateThemeConfig.js +13 -18
  132. package/package.json +19 -15
  133. package/src/getSwizzleConfig.ts +5 -5
  134. package/src/index.ts +4 -2
  135. package/src/theme/Admonition/index.tsx +161 -58
  136. package/src/{admonitions.css → theme/Admonition/styles.module.css} +14 -15
  137. package/src/theme/AnnouncementBar/index.tsx +3 -2
  138. package/src/theme/BackToTopButton/index.tsx +2 -1
  139. package/src/theme/BlogListPage/index.tsx +2 -11
  140. package/src/theme/BlogPostItem/Container/index.tsx +32 -0
  141. package/src/theme/BlogPostItem/Content/index.tsx +29 -0
  142. package/src/theme/BlogPostItem/Footer/ReadMoreLink/index.tsx +44 -0
  143. package/src/theme/BlogPostItem/Footer/index.tsx +60 -0
  144. package/src/theme/BlogPostItem/Footer/styles.module.css +10 -0
  145. package/src/theme/{BlogPostAuthor → BlogPostItem/Header/Author}/index.tsx +8 -3
  146. package/{lib/theme/BlogPostAuthors/index.js → src/theme/BlogPostItem/Header/Authors/index.tsx} +14 -3
  147. package/src/theme/{BlogPostAuthors → BlogPostItem/Header/Authors}/styles.module.css +0 -0
  148. package/src/theme/BlogPostItem/Header/Info/index.tsx +71 -0
  149. package/src/theme/BlogPostItem/Header/Info/styles.module.css +10 -0
  150. package/src/theme/BlogPostItem/Header/Title/index.tsx +33 -0
  151. package/{lib/theme/BlogPostItem → src/theme/BlogPostItem/Header/Title}/styles.module.css +2 -10
  152. package/src/theme/BlogPostItem/Header/index.tsx +21 -0
  153. package/src/theme/BlogPostItem/index.tsx +19 -145
  154. package/src/theme/BlogPostItems/index.tsx +30 -0
  155. package/src/theme/BlogPostPage/Metadata/index.tsx +44 -0
  156. package/src/theme/BlogPostPage/index.tsx +29 -62
  157. package/src/theme/BlogTagsListPage/index.tsx +1 -1
  158. package/src/theme/BlogTagsPostsPage/index.tsx +42 -35
  159. package/src/theme/CodeBlock/Container/index.tsx +3 -6
  160. package/src/theme/CodeBlock/Content/String.tsx +2 -3
  161. package/src/theme/CodeBlock/CopyButton/index.tsx +1 -0
  162. package/src/theme/CodeBlock/Line/styles.module.css +7 -7
  163. package/src/theme/ColorModeToggle/index.tsx +2 -2
  164. package/src/theme/DocBreadcrumbs/index.tsx +3 -3
  165. package/src/theme/DocCard/index.tsx +4 -1
  166. package/src/theme/DocCardList/index.tsx +2 -2
  167. package/src/theme/DocItem/Content/index.tsx +48 -0
  168. package/src/theme/{DocItemFooter → DocItem/Footer}/index.tsx +4 -5
  169. package/src/theme/{DocItemFooter → DocItem/Footer}/styles.module.css +0 -0
  170. package/src/theme/DocItem/Layout/index.tsx +68 -0
  171. package/src/theme/DocItem/Layout/styles.module.css +17 -0
  172. package/src/theme/DocItem/Metadata/index.tsx +22 -0
  173. package/src/theme/DocItem/Paginator/index.tsx +19 -0
  174. package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
  175. package/src/theme/DocItem/TOC/Mobile/index.tsx +27 -0
  176. package/src/theme/DocItem/{styles.module.css → TOC/Mobile/styles.module.css} +0 -9
  177. package/src/theme/DocItem/index.tsx +13 -115
  178. package/src/theme/DocPage/Layout/Main/index.tsx +1 -1
  179. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +1 -1
  180. package/src/theme/DocPage/Layout/Sidebar/index.tsx +2 -1
  181. package/src/theme/DocPage/Layout/index.tsx +1 -1
  182. package/src/theme/DocPage/index.tsx +2 -3
  183. package/src/theme/DocPaginator/index.tsx +0 -1
  184. package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +1 -1
  185. package/src/theme/DocSidebar/Desktop/Content/index.tsx +2 -2
  186. package/src/theme/DocSidebar/Mobile/index.tsx +1 -1
  187. package/src/theme/DocSidebarItem/Category/index.tsx +6 -4
  188. package/src/theme/DocSidebarItem/Link/index.tsx +3 -2
  189. package/src/theme/DocSidebarItems/index.tsx +1 -1
  190. package/src/theme/DocVersionBadge/index.tsx +2 -1
  191. package/src/theme/DocVersionBanner/index.tsx +2 -3
  192. package/src/theme/EditThisPage/index.tsx +1 -1
  193. package/src/theme/Footer/LinkItem/index.tsx +1 -1
  194. package/src/theme/Footer/Logo/index.tsx +7 -2
  195. package/src/theme/{IconArrow → Icon/Arrow}/index.tsx +1 -1
  196. package/src/theme/{IconClose → Icon/Close}/index.tsx +1 -1
  197. package/src/theme/{IconDarkMode → Icon/DarkMode}/index.tsx +1 -1
  198. package/src/theme/{IconEdit → Icon/Edit}/index.tsx +1 -1
  199. package/src/theme/{IconEdit → Icon/Edit}/styles.module.css +0 -0
  200. package/src/theme/{IconExternalLink → Icon/ExternalLink}/index.tsx +1 -1
  201. package/src/theme/{IconExternalLink → Icon/ExternalLink}/styles.module.css +0 -0
  202. package/src/theme/{IconHome → Icon/Home}/index.tsx +1 -1
  203. package/src/theme/{IconLanguage → Icon/Language}/index.tsx +1 -1
  204. package/src/theme/{IconLightMode → Icon/LightMode}/index.tsx +1 -1
  205. package/src/theme/{IconMenu → Icon/Menu}/index.tsx +1 -1
  206. package/src/theme/Layout/Provider/index.tsx +33 -0
  207. package/src/theme/Layout/index.tsx +12 -10
  208. package/{lib/theme/Layout/styles.css → src/theme/Layout/styles.module.css} +10 -12
  209. package/src/theme/Logo/index.tsx +49 -19
  210. package/src/theme/MDXComponents/Code.tsx +5 -2
  211. package/src/theme/MDXComponents/Details.tsx +2 -1
  212. package/src/theme/MDXComponents/Head.tsx +3 -5
  213. package/src/theme/MDXComponents/Pre.tsx +2 -1
  214. package/src/theme/MDXComponents/index.tsx +2 -0
  215. package/src/theme/MDXPage/index.tsx +6 -4
  216. package/src/theme/Navbar/Content/index.tsx +2 -2
  217. package/src/theme/Navbar/Layout/index.tsx +2 -2
  218. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +2 -2
  219. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +1 -1
  220. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +2 -1
  221. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +2 -1
  222. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +2 -2
  223. package/src/theme/Navbar/MobileSidebar/index.tsx +1 -1
  224. package/src/theme/NavbarItem/DocNavbarItem.tsx +1 -1
  225. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +1 -1
  226. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -4
  227. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +1 -1
  228. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +2 -3
  229. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -2
  230. package/src/theme/NavbarItem/NavbarNavLink.tsx +1 -1
  231. package/src/theme/NavbarItem/index.tsx +1 -1
  232. package/src/theme/SiteMetadata/index.tsx +2 -3
  233. package/src/theme/SkipToContent/index.tsx +1 -1
  234. package/src/theme/TOCItems/index.tsx +3 -3
  235. package/src/theme/Tabs/index.tsx +2 -2
  236. package/src/theme-classic.d.ts +128 -36
  237. package/src/validateThemeConfig.ts +14 -18
  238. package/lib/theme/LayoutProviders/index.d.ts +0 -9
  239. package/lib/theme/LayoutProviders/index.js +0 -33
  240. package/src/theme/LayoutProviders/index.tsx +0 -36
@@ -7,15 +7,14 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
+ import {useThemeConfig, usePrismTheme} from '@docusaurus/theme-common';
10
11
  import {
11
- useThemeConfig,
12
12
  parseCodeBlockTitle,
13
13
  parseLanguage,
14
14
  parseLines,
15
15
  containsLineNumbers,
16
- usePrismTheme,
17
16
  useCodeWordWrap,
18
- } from '@docusaurus/theme-common';
17
+ } from '@docusaurus/theme-common/internal';
19
18
  import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
20
19
  import Line from '@theme/CodeBlock/Line';
21
20
  import CopyButton from '@theme/CodeBlock/CopyButton';
@@ -7,6 +7,7 @@
7
7
 
8
8
  import React, {useCallback, useState, useRef, useEffect} from 'react';
9
9
  import clsx from 'clsx';
10
+ // @ts-expect-error: TODO, we need to make theme-classic have type: module
10
11
  import copy from 'copy-text-to-clipboard';
11
12
  import {translate} from '@docusaurus/Translate';
12
13
  import type {Props} from '@theme/CodeBlock/CopyButton';
@@ -5,13 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- :global(.theme-code-block-highlighted-line) {
9
- background-color: var(--docusaurus-highlighted-code-line-bg);
10
- display: block;
11
- margin: 0 calc(-1 * var(--ifm-pre-padding));
12
- padding: 0 var(--ifm-pre-padding);
13
- }
14
-
15
8
  /* Intentionally has zero specificity, so that to be able to override
16
9
  the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
17
10
  :where(:root) {
@@ -22,6 +15,13 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
22
15
  --docusaurus-highlighted-code-line-bg: rgb(100 100 100);
23
16
  }
24
17
 
18
+ :global(.theme-code-block-highlighted-line) {
19
+ background-color: var(--docusaurus-highlighted-code-line-bg);
20
+ display: block;
21
+ margin: 0 calc(-1 * var(--ifm-pre-padding));
22
+ padding: 0 var(--ifm-pre-padding);
23
+ }
24
+
25
25
  .codeLine {
26
26
  display: table-row;
27
27
  counter-increment: line-count;
@@ -9,8 +9,8 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import useIsBrowser from '@docusaurus/useIsBrowser';
11
11
  import {translate} from '@docusaurus/Translate';
12
- import IconLightMode from '@theme/IconLightMode';
13
- import IconDarkMode from '@theme/IconDarkMode';
12
+ import IconLightMode from '@theme/Icon/LightMode';
13
+ import IconDarkMode from '@theme/Icon/DarkMode';
14
14
  import type {Props} from '@theme/ColorModeToggle';
15
15
 
16
16
  import styles from './styles.module.css';
@@ -7,15 +7,15 @@
7
7
 
8
8
  import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
10
11
  import {
11
- ThemeClassNames,
12
12
  useSidebarBreadcrumbs,
13
13
  useHomePageRoute,
14
- } from '@docusaurus/theme-common';
14
+ } from '@docusaurus/theme-common/internal';
15
15
  import Link from '@docusaurus/Link';
16
16
  import useBaseUrl from '@docusaurus/useBaseUrl';
17
17
  import {translate} from '@docusaurus/Translate';
18
- import IconHome from '@theme/IconHome';
18
+ import IconHome from '@theme/Icon/Home';
19
19
 
20
20
  import styles from './styles.module.css';
21
21
 
@@ -8,7 +8,10 @@
8
8
  import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Link from '@docusaurus/Link';
11
- import {findFirstCategoryLink, useDocById} from '@docusaurus/theme-common';
11
+ import {
12
+ findFirstCategoryLink,
13
+ useDocById,
14
+ } from '@docusaurus/theme-common/internal';
12
15
  import isInternalUrl from '@docusaurus/isInternalUrl';
13
16
  import {translate} from '@docusaurus/Translate';
14
17
  import type {Props} from '@theme/DocCard';
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {findFirstCategoryLink} from '@docusaurus/theme-common';
10
+ import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
11
11
  import DocCard from '@theme/DocCard';
12
12
  import type {Props} from '@theme/DocCardList';
13
13
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
@@ -27,7 +27,7 @@ export default function DocCardList({items, className}: Props): JSX.Element {
27
27
  <section className={clsx('row', className)}>
28
28
  {filterItems(items).map((item, index) => (
29
29
  <article key={index} className="col col--6 margin-bottom--lg">
30
- <DocCard key={index} item={item} />
30
+ <DocCard item={item} />
31
31
  </article>
32
32
  ))}
33
33
  </section>
@@ -0,0 +1,48 @@
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} from '@docusaurus/theme-common';
11
+ import {useDoc} from '@docusaurus/theme-common/internal';
12
+ import Heading from '@theme/Heading';
13
+ import MDXContent from '@theme/MDXContent';
14
+ import type {Props} from '@theme/DocItem/Content';
15
+
16
+ /**
17
+ Title can be declared inside md content or declared through
18
+ front matter and added manually. To make both cases consistent,
19
+ the added title is added under the same div.markdown block
20
+ See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
21
+
22
+ We render a "synthetic title" if:
23
+ - user doesn't ask to hide it with front matter
24
+ - the markdown content does not already contain a top-level h1 heading
25
+ */
26
+ function useSyntheticTitle(): string | null {
27
+ const {metadata, frontMatter, contentTitle} = useDoc();
28
+ const shouldRender =
29
+ !frontMatter.hide_title && typeof contentTitle === 'undefined';
30
+ if (!shouldRender) {
31
+ return null;
32
+ }
33
+ return metadata.title;
34
+ }
35
+
36
+ export default function DocItemContent({children}: Props): JSX.Element {
37
+ const syntheticTitle = useSyntheticTitle();
38
+ return (
39
+ <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
40
+ {syntheticTitle && (
41
+ <header>
42
+ <Heading as="h1">{syntheticTitle}</Heading>
43
+ </header>
44
+ )}
45
+ <MDXContent>{children}</MDXContent>
46
+ </div>
47
+ );
48
+ }
@@ -8,12 +8,12 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {useDoc, type DocContextValue} from '@docusaurus/theme-common/internal';
11
12
  import LastUpdated from '@theme/LastUpdated';
12
13
  import EditThisPage from '@theme/EditThisPage';
13
14
  import TagsListInline, {
14
15
  type Props as TagsListInlineProps,
15
16
  } from '@theme/TagsListInline';
16
- import type {Props} from '@theme/DocItem';
17
17
 
18
18
  import styles from './styles.module.css';
19
19
 
@@ -32,7 +32,7 @@ function TagsRow(props: TagsListInlineProps) {
32
32
  }
33
33
 
34
34
  type EditMetaRowProps = Pick<
35
- Props['content']['metadata'],
35
+ DocContextValue['metadata'],
36
36
  'editUrl' | 'lastUpdatedAt' | 'lastUpdatedBy' | 'formattedLastUpdatedAt'
37
37
  >;
38
38
  function EditMetaRow({
@@ -58,9 +58,8 @@ function EditMetaRow({
58
58
  );
59
59
  }
60
60
 
61
- export default function DocItemFooter(props: Props): JSX.Element | null {
62
- const {content: DocContent} = props;
63
- const {metadata} = DocContent;
61
+ export default function DocItemFooter(): JSX.Element | null {
62
+ const {metadata} = useDoc();
64
63
  const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} =
65
64
  metadata;
66
65
 
@@ -0,0 +1,68 @@
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 {useWindowSize} from '@docusaurus/theme-common';
11
+ import {useDoc} from '@docusaurus/theme-common/internal';
12
+ import DocItemPaginator from '@theme/DocItem/Paginator';
13
+ import DocVersionBanner from '@theme/DocVersionBanner';
14
+ import DocVersionBadge from '@theme/DocVersionBadge';
15
+ import DocItemFooter from '@theme/DocItem/Footer';
16
+ import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
17
+ import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
18
+ import DocItemContent from '@theme/DocItem/Content';
19
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
20
+ import type {Props} from '@theme/DocItem/Layout';
21
+
22
+ import styles from './styles.module.css';
23
+
24
+ /**
25
+ * Decide if the toc should be rendered, on mobile or desktop viewports
26
+ */
27
+ function useDocTOC() {
28
+ const {frontMatter, toc} = useDoc();
29
+ const windowSize = useWindowSize();
30
+
31
+ const hidden = frontMatter.hide_table_of_contents;
32
+ const canRender = !hidden && toc.length > 0;
33
+
34
+ const mobile = canRender ? <DocItemTOCMobile /> : undefined;
35
+
36
+ const desktop =
37
+ canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? (
38
+ <DocItemTOCDesktop />
39
+ ) : undefined;
40
+
41
+ return {
42
+ hidden,
43
+ mobile,
44
+ desktop,
45
+ };
46
+ }
47
+
48
+ export default function DocItemLayout({children}: Props): JSX.Element {
49
+ const docTOC = useDocTOC();
50
+ return (
51
+ <div className="row">
52
+ <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
53
+ <DocVersionBanner />
54
+ <div className={styles.docItemContainer}>
55
+ <article>
56
+ <DocBreadcrumbs />
57
+ <DocVersionBadge />
58
+ {docTOC.mobile}
59
+ <DocItemContent>{children}</DocItemContent>
60
+ <DocItemFooter />
61
+ </article>
62
+ <DocItemPaginator />
63
+ </div>
64
+ </div>
65
+ {docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
66
+ </div>
67
+ );
68
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .docItemContainer header + *,
9
+ .docItemContainer article > *:first-child {
10
+ margin-top: 0;
11
+ }
12
+
13
+ @media (min-width: 997px) {
14
+ .docItemCol {
15
+ max-width: 75% !important;
16
+ }
17
+ }
@@ -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 {PageMetadata} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
11
+
12
+ export default function DocItemMetadata(): JSX.Element {
13
+ const {metadata, frontMatter, assets} = useDoc();
14
+ return (
15
+ <PageMetadata
16
+ title={metadata.title}
17
+ description={metadata.description}
18
+ keywords={frontMatter.keywords}
19
+ image={assets.image ?? frontMatter.image}
20
+ />
21
+ );
22
+ }
@@ -0,0 +1,19 @@
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 {useDoc} from '@docusaurus/theme-common/internal';
10
+ import DocPaginator from '@theme/DocPaginator';
11
+
12
+ /**
13
+ * This extra component is needed, because <DocPaginator> should remain generic.
14
+ * DocPaginator is used in non-docs contexts too: generated-index pages...
15
+ */
16
+ export default function DocItemPaginator(): JSX.Element {
17
+ const {metadata} = useDoc();
18
+ return <DocPaginator previous={metadata.previous} next={metadata.next} />;
19
+ }
@@ -0,0 +1,24 @@
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 {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
11
+
12
+ import TOC from '@theme/TOC';
13
+
14
+ export default function DocItemTOCDesktop(): JSX.Element {
15
+ const {toc, frontMatter} = useDoc();
16
+ return (
17
+ <TOC
18
+ toc={toc}
19
+ minHeadingLevel={frontMatter.toc_min_heading_level}
20
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
21
+ className={ThemeClassNames.docs.docTocDesktop}
22
+ />
23
+ );
24
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {useDoc} from '@docusaurus/theme-common/internal';
12
+
13
+ import TOCCollapsible from '@theme/TOCCollapsible';
14
+
15
+ import styles from './styles.module.css';
16
+
17
+ export default function DocItemTOCMobile(): JSX.Element {
18
+ const {toc, frontMatter} = useDoc();
19
+ return (
20
+ <TOCCollapsible
21
+ toc={toc}
22
+ minHeadingLevel={frontMatter.toc_min_heading_level}
23
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
24
+ className={clsx(ThemeClassNames.docs.docTocMobile, styles.tocMobile)}
25
+ />
26
+ );
27
+ }
@@ -5,16 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docItemContainer header + *,
9
- .docItemContainer article > *:first-child {
10
- margin-top: 0;
11
- }
12
-
13
8
  @media (min-width: 997px) {
14
- .docItemCol {
15
- max-width: 75% !important;
16
- }
17
-
18
9
  /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
19
10
  .tocMobile {
20
11
  display: none;
@@ -6,125 +6,23 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
- import {
11
- PageMetadata,
12
- HtmlClassNameProvider,
13
- ThemeClassNames,
14
- useWindowSize,
15
- } from '@docusaurus/theme-common';
16
- import DocPaginator from '@theme/DocPaginator';
17
- import DocVersionBanner from '@theme/DocVersionBanner';
18
- import DocVersionBadge from '@theme/DocVersionBadge';
19
- import DocItemFooter from '@theme/DocItemFooter';
20
- import TOC from '@theme/TOC';
21
- import TOCCollapsible from '@theme/TOCCollapsible';
22
- import Heading from '@theme/Heading';
23
- import DocBreadcrumbs from '@theme/DocBreadcrumbs';
24
- import MDXContent from '@theme/MDXContent';
9
+ import {HtmlClassNameProvider} from '@docusaurus/theme-common';
10
+ import {DocProvider} from '@docusaurus/theme-common/internal';
11
+ import DocItemMetadata from '@theme/DocItem/Metadata';
12
+ import DocItemLayout from '@theme/DocItem/Layout';
25
13
  import type {Props} from '@theme/DocItem';
26
14
 
27
- import styles from './styles.module.css';
28
-
29
- function DocItemMetadata(props: Props): JSX.Element {
30
- const {content: DocContent} = props;
31
- const {metadata, frontMatter, assets} = DocContent;
32
- const {keywords} = frontMatter;
33
- const {description, title} = metadata;
34
- const image = assets.image ?? frontMatter.image;
35
-
36
- return <PageMetadata {...{title, description, keywords, image}} />;
37
- }
38
-
39
- function DocItemContent(props: Props): JSX.Element {
40
- const {content: DocContent} = props;
41
- const {metadata, frontMatter} = DocContent;
42
- const {
43
- hide_title: hideTitle,
44
- hide_table_of_contents: hideTableOfContents,
45
- toc_min_heading_level: tocMinHeadingLevel,
46
- toc_max_heading_level: tocMaxHeadingLevel,
47
- } = frontMatter;
48
- const {title} = metadata;
49
-
50
- // We only add a title if:
51
- // - user doesn't ask to hide it with front matter
52
- // - the markdown content does not already contain a top-level h1 heading
53
- const shouldAddTitle =
54
- !hideTitle && typeof DocContent.contentTitle === 'undefined';
55
-
56
- const windowSize = useWindowSize();
57
-
58
- const canRenderTOC =
59
- !hideTableOfContents && DocContent.toc && DocContent.toc.length > 0;
60
-
61
- const renderTocDesktop =
62
- canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr');
63
-
64
- return (
65
- <div className="row">
66
- <div className={clsx('col', !hideTableOfContents && styles.docItemCol)}>
67
- <DocVersionBanner />
68
- <div className={styles.docItemContainer}>
69
- <article>
70
- <DocBreadcrumbs />
71
- <DocVersionBadge />
72
-
73
- {canRenderTOC && (
74
- <TOCCollapsible
75
- toc={DocContent.toc}
76
- minHeadingLevel={tocMinHeadingLevel}
77
- maxHeadingLevel={tocMaxHeadingLevel}
78
- className={clsx(
79
- ThemeClassNames.docs.docTocMobile,
80
- styles.tocMobile,
81
- )}
82
- />
83
- )}
84
-
85
- <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
86
- {/*
87
- Title can be declared inside md content or declared through
88
- front matter and added manually. To make both cases consistent,
89
- the added title is added under the same div.markdown block
90
- See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
91
- */}
92
- {shouldAddTitle && (
93
- <header>
94
- <Heading as="h1">{title}</Heading>
95
- </header>
96
- )}
97
- <MDXContent>
98
- <DocContent />
99
- </MDXContent>
100
- </div>
101
-
102
- <DocItemFooter {...props} />
103
- </article>
104
-
105
- <DocPaginator previous={metadata.previous} next={metadata.next} />
106
- </div>
107
- </div>
108
- {renderTocDesktop && (
109
- <div className="col col--3">
110
- <TOC
111
- toc={DocContent.toc}
112
- minHeadingLevel={tocMinHeadingLevel}
113
- maxHeadingLevel={tocMaxHeadingLevel}
114
- className={ThemeClassNames.docs.docTocDesktop}
115
- />
116
- </div>
117
- )}
118
- </div>
119
- );
120
- }
121
-
122
15
  export default function DocItem(props: Props): JSX.Element {
123
16
  const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
17
+ const MDXComponent = props.content;
124
18
  return (
125
- <HtmlClassNameProvider className={docHtmlClassName}>
126
- <DocItemMetadata {...props} />
127
- <DocItemContent {...props} />
128
- </HtmlClassNameProvider>
19
+ <DocProvider content={props.content}>
20
+ <HtmlClassNameProvider className={docHtmlClassName}>
21
+ <DocItemMetadata />
22
+ <DocItemLayout>
23
+ <MDXComponent />
24
+ </DocItemLayout>
25
+ </HtmlClassNameProvider>
26
+ </DocProvider>
129
27
  );
130
28
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {useDocsSidebar} from '@docusaurus/theme-common';
10
+ import {useDocsSidebar} from '@docusaurus/theme-common/internal';
11
11
  import type {Props} from '@theme/DocPage/Layout/Main';
12
12
 
13
13
  import styles from './styles.module.css';
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import {translate} from '@docusaurus/Translate';
10
- import IconArrow from '@theme/IconArrow';
10
+ import IconArrow from '@theme/Icon/Arrow';
11
11
  import type {Props} from '@theme/DocPage/Layout/Sidebar/ExpandButton';
12
12
 
13
13
  import styles from './styles.module.css';
@@ -7,7 +7,8 @@
7
7
 
8
8
  import React, {type ReactNode, useState, useCallback} from 'react';
9
9
  import clsx from 'clsx';
10
- import {ThemeClassNames, useDocsSidebar} from '@docusaurus/theme-common';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {useDocsSidebar} from '@docusaurus/theme-common/internal';
11
12
  import {useLocation} from '@docusaurus/router';
12
13
  import DocSidebar from '@theme/DocSidebar';
13
14
  import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import React, {useState} from 'react';
9
- import {useDocsSidebar} from '@docusaurus/theme-common';
9
+ import {useDocsSidebar} from '@docusaurus/theme-common/internal';
10
10
  import Layout from '@theme/Layout';
11
11
  import BackToTopButton from '@theme/BackToTopButton';
12
12
  import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
@@ -7,14 +7,13 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
+ import {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
10
11
  import {
11
- HtmlClassNameProvider,
12
- ThemeClassNames,
13
12
  docVersionSearchTag,
14
13
  DocsSidebarProvider,
15
14
  DocsVersionProvider,
16
15
  useDocRouteMetadata,
17
- } from '@docusaurus/theme-common';
16
+ } from '@docusaurus/theme-common/internal';
18
17
  import DocPageLayout from '@theme/DocPage/Layout';
19
18
  import NotFound from '@theme/NotFound';
20
19
  import SearchMetadata from '@theme/SearchMetadata';
@@ -12,7 +12,6 @@ import type {Props} from '@theme/DocPaginator';
12
12
 
13
13
  export default function DocPaginator(props: Props): JSX.Element {
14
14
  const {previous, next} = props;
15
-
16
15
  return (
17
16
  <nav
18
17
  className="pagination-nav docusaurus-mt-lg"
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {translate} from '@docusaurus/Translate';
11
- import IconArrow from '@theme/IconArrow';
11
+ import IconArrow from '@theme/Icon/Arrow';
12
12
  import type {Props} from '@theme/DocSidebar/Desktop/CollapseButton';
13
13
 
14
14
  import styles from './styles.module.css';
@@ -7,11 +7,11 @@
7
7
 
8
8
  import React, {useState} from 'react';
9
9
  import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
10
11
  import {
11
- ThemeClassNames,
12
12
  useAnnouncementBar,
13
13
  useScrollPosition,
14
- } from '@docusaurus/theme-common';
14
+ } from '@docusaurus/theme-common/internal';
15
15
  import DocSidebarItems from '@theme/DocSidebarItems';
16
16
  import type {Props} from '@theme/DocSidebar/Desktop/Content';
17
17
 
@@ -11,8 +11,8 @@ import {
11
11
  NavbarSecondaryMenuFiller,
12
12
  type NavbarSecondaryMenuComponent,
13
13
  ThemeClassNames,
14
- useNavbarMobileSidebar,
15
14
  } from '@docusaurus/theme-common';
15
+ import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
16
16
  import DocSidebarItems from '@theme/DocSidebarItems';
17
17
  import type {Props} from '@theme/DocSidebar/Mobile';
18
18