@docusaurus/theme-classic 2.0.0-beta.13 → 2.0.0-beta.15

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 (299) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +7 -16
  3. package/lib/theme-classic.d.ts +111 -188
  4. package/lib/translations.js +13 -4
  5. package/lib/validateThemeConfig.js +18 -4
  6. package/lib-next/theme/Admonition/index.js +101 -0
  7. package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
  8. package/lib-next/theme/BlogListPaginator/index.js +12 -12
  9. package/lib-next/theme/BlogPostAuthor/index.js +1 -1
  10. package/lib-next/theme/BlogPostAuthors/index.js +12 -2
  11. package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
  12. package/lib-next/theme/BlogPostItem/index.js +12 -15
  13. package/lib-next/theme/BlogPostPage/index.js +10 -7
  14. package/lib-next/theme/BlogPostPaginator/index.js +11 -15
  15. package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
  16. package/lib-next/theme/CodeBlock/index.js +51 -10
  17. package/lib-next/theme/CodeBlock/styles.module.css +18 -7
  18. package/lib-next/theme/DocCard/styles.module.css +3 -3
  19. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
  20. package/lib-next/theme/DocItem/index.js +9 -6
  21. package/lib-next/theme/DocItem/styles.module.css +2 -2
  22. package/lib-next/theme/DocPage/index.js +7 -3
  23. package/lib-next/theme/DocPage/styles.module.css +1 -0
  24. package/lib-next/theme/DocPaginator/index.js +11 -13
  25. package/lib-next/theme/DocSidebar/index.js +2 -2
  26. package/lib-next/theme/DocSidebar/styles.module.css +1 -0
  27. package/lib-next/theme/DocSidebarItem/index.js +43 -21
  28. package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
  29. package/lib-next/theme/DocSidebarItems/index.js +28 -0
  30. package/{lib/theme/DocSidebarItem → lib-next/theme/DocSidebarItems}/styles.module.css +1 -0
  31. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  32. package/lib-next/theme/Footer/index.js +73 -35
  33. package/lib-next/theme/Footer/styles.module.css +2 -1
  34. package/lib-next/theme/Heading/index.js +39 -43
  35. package/lib-next/theme/Heading/styles.css +1 -1
  36. package/lib-next/theme/Layout/index.js +1 -2
  37. package/lib-next/theme/LayoutHead/index.js +5 -9
  38. package/lib-next/theme/LayoutProviders/index.js +6 -6
  39. package/lib-next/theme/MDXComponents/index.js +18 -31
  40. package/lib-next/theme/MDXComponents/styles.css +4 -0
  41. package/lib-next/theme/MDXPage/index.js +3 -10
  42. package/lib-next/theme/Navbar/index.js +6 -6
  43. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  44. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  45. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
  46. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
  47. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  48. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +6 -7
  49. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  50. package/lib-next/theme/NavbarItem/index.js +1 -2
  51. package/lib-next/theme/{UserPreferencesContext.js → NavbarItem/utils.js} +3 -3
  52. package/lib-next/theme/PaginatorNavLink/index.js +20 -0
  53. package/lib-next/theme/SkipToContent/index.js +1 -1
  54. package/lib-next/theme/SkipToContent/styles.module.css +7 -0
  55. package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
  56. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  57. package/lib-next/theme/Tabs/index.js +20 -10
  58. package/lib-next/theme/Tag/styles.module.css +4 -4
  59. package/lib-next/theme/ThemedImage/index.js +2 -2
  60. package/lib-next/theme/Toggle/styles.module.css +16 -15
  61. package/lib-next/theme/prism-include-languages.js +10 -3
  62. package/package.json +17 -19
  63. package/src/index.ts +12 -26
  64. package/src/theme/Admonition/index.tsx +106 -0
  65. package/src/theme/BackToTopButton/styles.module.css +1 -1
  66. package/src/theme/BlogListPaginator/index.tsx +12 -12
  67. package/src/theme/BlogPostAuthor/index.tsx +1 -1
  68. package/src/theme/BlogPostAuthors/index.tsx +12 -2
  69. package/src/theme/BlogPostAuthors/styles.module.css +10 -0
  70. package/src/theme/BlogPostItem/index.tsx +13 -15
  71. package/src/theme/BlogPostPage/index.tsx +10 -7
  72. package/src/theme/BlogPostPaginator/index.tsx +11 -15
  73. package/src/theme/BlogSidebar/styles.module.css +2 -0
  74. package/src/theme/CodeBlock/index.tsx +52 -11
  75. package/src/theme/CodeBlock/styles.module.css +18 -7
  76. package/src/theme/DocCard/index.tsx +2 -2
  77. package/src/theme/DocCard/styles.module.css +3 -3
  78. package/src/theme/DocCardList/index.tsx +1 -1
  79. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
  80. package/src/theme/DocItem/index.tsx +9 -6
  81. package/src/theme/DocItem/styles.module.css +2 -2
  82. package/src/theme/DocItemFooter/index.tsx +1 -1
  83. package/src/theme/DocPage/index.tsx +8 -4
  84. package/src/theme/DocPage/styles.module.css +1 -0
  85. package/src/theme/DocPaginator/index.tsx +13 -15
  86. package/src/theme/DocSidebar/index.tsx +3 -3
  87. package/src/theme/DocSidebar/styles.module.css +1 -0
  88. package/src/theme/DocSidebarItem/index.tsx +34 -23
  89. package/src/theme/DocSidebarItem/styles.module.css +1 -0
  90. package/src/theme/DocSidebarItems/index.tsx +32 -0
  91. package/{lib/theme/DocItemFooter → src/theme/DocSidebarItems}/styles.module.css +10 -8
  92. package/src/theme/DocVersionBanner/index.tsx +3 -3
  93. package/src/theme/Footer/index.tsx +84 -38
  94. package/src/theme/Footer/styles.module.css +2 -1
  95. package/src/theme/Heading/index.tsx +39 -47
  96. package/src/theme/Heading/styles.css +1 -1
  97. package/src/theme/Layout/index.tsx +1 -2
  98. package/src/theme/LayoutHead/index.tsx +4 -8
  99. package/src/theme/LayoutProviders/index.tsx +6 -6
  100. package/src/theme/MDXComponents/index.tsx +26 -37
  101. package/src/theme/MDXComponents/styles.css +4 -0
  102. package/src/theme/MDXPage/index.tsx +3 -11
  103. package/src/theme/Navbar/index.tsx +7 -7
  104. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  105. package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
  106. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
  107. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
  108. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
  109. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +6 -7
  110. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  111. package/src/theme/NavbarItem/index.tsx +3 -5
  112. package/{lib-next/theme/hooks/styles.css → src/theme/NavbarItem/utils.ts} +3 -3
  113. package/src/theme/PaginatorNavLink/index.tsx +22 -0
  114. package/src/theme/SkipToContent/index.tsx +1 -1
  115. package/src/theme/SkipToContent/styles.module.css +7 -0
  116. package/src/theme/TOCCollapsible/styles.module.css +2 -2
  117. package/src/theme/TOCItems/index.tsx +2 -2
  118. package/src/theme/Tabs/index.tsx +25 -10
  119. package/src/theme/Tag/styles.module.css +4 -4
  120. package/src/theme/TagsListByLetter/index.tsx +1 -1
  121. package/src/theme/ThemedImage/index.tsx +2 -2
  122. package/src/theme/Toggle/index.tsx +1 -1
  123. package/src/theme/Toggle/styles.module.css +16 -15
  124. package/src/theme/prism-include-languages.ts +10 -3
  125. package/src/theme-classic.d.ts +111 -188
  126. package/src/translations.ts +36 -16
  127. package/src/validateThemeConfig.ts +25 -4
  128. package/babel.config.js +0 -35
  129. package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  130. package/lib/__tests__/translations.test.js +0 -112
  131. package/lib/__tests__/validateThemeConfig.test.js +0 -607
  132. package/lib/theme/AnnouncementBar/index.js +0 -68
  133. package/lib/theme/AnnouncementBar/styles.module.css +0 -63
  134. package/lib/theme/BackToTopButton/index.js +0 -140
  135. package/lib/theme/BackToTopButton/styles.module.css +0 -42
  136. package/lib/theme/BlogArchivePage/index.js +0 -89
  137. package/lib/theme/BlogLayout/index.js +0 -51
  138. package/lib/theme/BlogListPage/index.js +0 -60
  139. package/lib/theme/BlogListPaginator/index.js +0 -63
  140. package/lib/theme/BlogPostAuthor/index.js +0 -51
  141. package/lib/theme/BlogPostAuthor/styles.module.css +0 -12
  142. package/lib/theme/BlogPostAuthors/index.js +0 -47
  143. package/lib/theme/BlogPostAuthors/styles.module.css +0 -11
  144. package/lib/theme/BlogPostItem/index.js +0 -152
  145. package/lib/theme/BlogPostItem/styles.module.css +0 -18
  146. package/lib/theme/BlogPostPage/index.js +0 -82
  147. package/lib/theme/BlogPostPaginator/index.js +0 -64
  148. package/lib/theme/BlogSidebar/index.js +0 -49
  149. package/lib/theme/BlogSidebar/styles.module.css +0 -44
  150. package/lib/theme/BlogTagsListPage/index.js +0 -40
  151. package/lib/theme/BlogTagsPostsPage/index.js +0 -86
  152. package/lib/theme/CodeBlock/index.js +0 -133
  153. package/lib/theme/CodeBlock/styles.module.css +0 -65
  154. package/lib/theme/Details/index.js +0 -30
  155. package/lib/theme/Details/styles.module.css +0 -13
  156. package/lib/theme/DocCard/index.js +0 -84
  157. package/lib/theme/DocCard/styles.module.css +0 -43
  158. package/lib/theme/DocCardList/index.js +0 -28
  159. package/lib/theme/DocCategoryGeneratedIndexPage/index.js +0 -57
  160. package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +0 -18
  161. package/lib/theme/DocItem/index.js +0 -112
  162. package/lib/theme/DocItem/styles.module.css +0 -22
  163. package/lib/theme/DocItemFooter/index.js +0 -79
  164. package/lib/theme/DocPage/index.js +0 -154
  165. package/lib/theme/DocPage/styles.module.css +0 -85
  166. package/lib/theme/DocPaginator/index.js +0 -62
  167. package/lib/theme/DocSidebar/index.js +0 -134
  168. package/lib/theme/DocSidebar/styles.module.css +0 -106
  169. package/lib/theme/DocSidebarItem/index.js +0 -209
  170. package/lib/theme/DocTagDocListPage/index.js +0 -89
  171. package/lib/theme/DocTagsListPage/index.js +0 -44
  172. package/lib/theme/DocVersionBadge/index.js +0 -34
  173. package/lib/theme/DocVersionBanner/index.js +0 -130
  174. package/lib/theme/EditThisPage/index.js +0 -33
  175. package/lib/theme/ErrorPageContent.js +0 -43
  176. package/lib/theme/Footer/index.js +0 -119
  177. package/lib/theme/Footer/styles.module.css +0 -15
  178. package/lib/theme/Heading/index.js +0 -71
  179. package/lib/theme/Heading/styles.css +0 -22
  180. package/lib/theme/Heading/styles.module.css +0 -19
  181. package/lib/theme/IconArrow/index.js +0 -28
  182. package/lib/theme/IconClose/index.js +0 -31
  183. package/lib/theme/IconEdit/index.js +0 -34
  184. package/lib/theme/IconEdit/styles.module.css +0 -11
  185. package/lib/theme/IconExternalLink/index.js +0 -30
  186. package/lib/theme/IconExternalLink/styles.module.css +0 -12
  187. package/lib/theme/IconLanguage/index.js +0 -29
  188. package/lib/theme/IconMenu/index.js +0 -30
  189. package/lib/theme/LastUpdated/index.js +0 -63
  190. package/lib/theme/Layout/index.js +0 -68
  191. package/lib/theme/Layout/styles.css +0 -27
  192. package/lib/theme/LayoutHead/index.js +0 -149
  193. package/lib/theme/LayoutProviders/index.js +0 -40
  194. package/lib/theme/Logo/index.js +0 -62
  195. package/lib/theme/MDXComponents/index.js +0 -106
  196. package/lib/theme/MDXComponents/styles.css +0 -11
  197. package/lib/theme/MDXPage/index.js +0 -67
  198. package/lib/theme/MDXPage/styles.module.css +0 -10
  199. package/lib/theme/Navbar/index.js +0 -267
  200. package/lib/theme/Navbar/styles.module.css +0 -27
  201. package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -113
  202. package/lib/theme/NavbarItem/DocNavbarItem.js +0 -62
  203. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -83
  204. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
  205. package/lib/theme/NavbarItem/DropdownNavbarItem.js +0 -155
  206. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +0 -68
  207. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +0 -11
  208. package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
  209. package/lib/theme/NavbarItem/index.js +0 -74
  210. package/lib/theme/NotFound.js +0 -57
  211. package/lib/theme/SearchBar.js +0 -15
  212. package/lib/theme/SearchMetadata/index.js +0 -33
  213. package/lib/theme/Seo/index.js +0 -52
  214. package/lib/theme/SkipToContent/index.js +0 -71
  215. package/lib/theme/SkipToContent/styles.module.css +0 -14
  216. package/lib/theme/TOC/index.js +0 -39
  217. package/lib/theme/TOC/styles.module.css +0 -23
  218. package/lib/theme/TOCCollapsible/index.js +0 -53
  219. package/lib/theme/TOCCollapsible/styles.module.css +0 -50
  220. package/lib/theme/TOCInline/index.js +0 -33
  221. package/lib/theme/TOCInline/styles.module.css +0 -12
  222. package/lib/theme/TOCItems/index.js +0 -78
  223. package/lib/theme/TabItem/index.js +0 -32
  224. package/lib/theme/Tabs/__tests__/index.test.js +0 -123
  225. package/lib/theme/Tabs/index.js +0 -173
  226. package/lib/theme/Tabs/styles.module.css +0 -10
  227. package/lib/theme/Tag/index.js +0 -40
  228. package/lib/theme/Tag/styles.module.css +0 -70
  229. package/lib/theme/TagsListByLetter/index.js +0 -48
  230. package/lib/theme/TagsListByLetter/styles.module.css +0 -11
  231. package/lib/theme/TagsListInline/index.js +0 -44
  232. package/lib/theme/TagsListInline/styles.module.css +0 -15
  233. package/lib/theme/ThemeContext.js +0 -21
  234. package/lib/theme/ThemeProvider/index.js +0 -43
  235. package/lib/theme/ThemedImage/index.js +0 -47
  236. package/lib/theme/ThemedImage/styles.module.css +0 -18
  237. package/lib/theme/Toggle/index.js +0 -91
  238. package/lib/theme/Toggle/styles.module.css +0 -105
  239. package/lib/theme/UserPreferencesContext.js +0 -18
  240. package/lib/theme/UserPreferencesProvider/index.js +0 -41
  241. package/lib/theme/hooks/styles.css +0 -10
  242. package/lib/theme/hooks/useDocs.js +0 -18
  243. package/lib/theme/hooks/useHideableNavbar.js +0 -74
  244. package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
  245. package/lib/theme/hooks/useLocationHash.js +0 -28
  246. package/lib/theme/hooks/useLockBodyScroll.js +0 -26
  247. package/lib/theme/hooks/usePrismTheme.js +0 -36
  248. package/lib/theme/hooks/useTabGroupChoice.js +0 -51
  249. package/lib/theme/hooks/useTheme.js +0 -97
  250. package/lib/theme/hooks/useThemeContext.js +0 -31
  251. package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
  252. package/lib/theme/hooks/useWindowSize.js +0 -68
  253. package/lib/theme/prism-include-languages.js +0 -40
  254. package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  255. package/lib-next/__tests__/translations.test.js +0 -128
  256. package/lib-next/__tests__/validateThemeConfig.test.js +0 -607
  257. package/lib-next/admonitions.css +0 -35
  258. package/lib-next/deps.d.ts +0 -13
  259. package/lib-next/index.js +0 -227
  260. package/lib-next/prism-include-languages.js +0 -9
  261. package/lib-next/theme/ThemeContext.js +0 -9
  262. package/lib-next/theme/ThemeProvider/index.js +0 -28
  263. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  264. package/lib-next/theme/hooks/useDocs.js +0 -10
  265. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  266. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  267. package/lib-next/theme/hooks/useLocationHash.js +0 -20
  268. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  269. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  270. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  271. package/lib-next/theme/hooks/useTheme.js +0 -81
  272. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  273. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  274. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  275. package/lib-next/theme-classic.d.ts +0 -806
  276. package/lib-next/translations.js +0 -141
  277. package/lib-next/types.d.ts +0 -11
  278. package/lib-next/validateThemeConfig.js +0 -344
  279. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  280. package/src/__tests__/translations.test.ts +0 -116
  281. package/src/__tests__/validateThemeConfig.test.js +0 -607
  282. package/src/theme/Tabs/__tests__/index.test.tsx +0 -129
  283. package/src/theme/ThemeContext.ts +0 -15
  284. package/src/theme/ThemeProvider/index.tsx +0 -28
  285. package/src/theme/UserPreferencesContext.ts +0 -12
  286. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  287. package/src/theme/hooks/styles.css +0 -10
  288. package/src/theme/hooks/useDocs.ts +0 -11
  289. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  290. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  291. package/src/theme/hooks/useLocationHash.ts +0 -25
  292. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  293. package/src/theme/hooks/usePrismTheme.ts +0 -22
  294. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  295. package/src/theme/hooks/useTheme.ts +0 -91
  296. package/src/theme/hooks/useThemeContext.ts +0 -23
  297. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  298. package/src/theme/hooks/useWindowSize.ts +0 -69
  299. package/tsconfig.json +0 -11
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useEffect, useState} from 'react';
8
+ import React, {isValidElement, useEffect, useState} from 'react';
9
9
  import clsx from 'clsx';
10
- import Highlight, {defaultProps, Language} from 'prism-react-renderer';
10
+ import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
11
11
  import copy from 'copy-text-to-clipboard';
12
12
  import Translate, {translate} from '@docusaurus/Translate';
13
13
  import {
@@ -15,17 +15,19 @@ import {
15
15
  parseCodeBlockTitle,
16
16
  parseLanguage,
17
17
  parseLines,
18
+ ThemeClassNames,
19
+ usePrismTheme,
18
20
  } from '@docusaurus/theme-common';
19
- import usePrismTheme from '@theme/hooks/usePrismTheme';
20
21
  import type {Props} from '@theme/CodeBlock';
21
22
 
22
23
  import styles from './styles.module.css';
23
24
 
24
25
  export default function CodeBlock({
25
26
  children,
26
- className: blockClassName,
27
+ className: blockClassName = '',
27
28
  metastring,
28
29
  title,
30
+ language: languageProp,
29
31
  }: Props): JSX.Element {
30
32
  const {prism} = useThemeConfig();
31
33
 
@@ -42,19 +44,49 @@ export default function CodeBlock({
42
44
  setMounted(true);
43
45
  }, []);
44
46
 
45
- // TODO: the title is provided by MDX as props automatically
46
- // so we probably don't need to parse the metastring
47
- // (note: title="xyz" => title prop still has the quotes)
47
+ // We still parse the metastring in case we want to support more syntax in the
48
+ // future. Note that MDX doesn't strip quotes when parsing metastring:
49
+ // "title=\"xyz\"" => title: "\"xyz\""
48
50
  const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
49
51
  const prismTheme = usePrismTheme();
50
52
 
51
- // In case interleaved Markdown (e.g. when using CodeBlock as standalone component).
53
+ // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
54
+ // When the children is not a simple string, we just return a styled block without actually highlighting.
55
+ if (React.Children.toArray(children).some((el) => isValidElement(el))) {
56
+ return (
57
+ <Highlight
58
+ {...defaultProps}
59
+ key={String(mounted)}
60
+ theme={prismTheme}
61
+ code=""
62
+ language={'text' as Language}>
63
+ {({className, style}) => (
64
+ <pre
65
+ /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
66
+ tabIndex={0}
67
+ className={clsx(
68
+ className,
69
+ styles.codeBlockStandalone,
70
+ 'thin-scrollbar',
71
+ styles.codeBlockContainer,
72
+ blockClassName,
73
+ ThemeClassNames.common.codeBlock,
74
+ )}
75
+ style={style}>
76
+ <code className={styles.codeBlockLines}>{children}</code>
77
+ </pre>
78
+ )}
79
+ </Highlight>
80
+ );
81
+ }
82
+
83
+ // The children is now guaranteed to be one/more plain strings
52
84
  const content = Array.isArray(children)
53
85
  ? children.join('')
54
86
  : (children as string);
55
87
 
56
88
  const language =
57
- parseLanguage(blockClassName) ?? (prism.defaultLanguage as Language);
89
+ languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
58
90
  const {highlightLines, code} = parseLines(content, metastring, language);
59
91
 
60
92
  const handleCopyCode = () => {
@@ -70,9 +102,18 @@ export default function CodeBlock({
70
102
  key={String(mounted)}
71
103
  theme={prismTheme}
72
104
  code={code}
73
- language={language}>
105
+ language={(language ?? 'text') as Language}>
74
106
  {({className, style, tokens, getLineProps, getTokenProps}) => (
75
- <div className={clsx(styles.codeBlockContainer, blockClassName)}>
107
+ <div
108
+ className={clsx(
109
+ styles.codeBlockContainer,
110
+ blockClassName,
111
+ {
112
+ [`language-${language}`]:
113
+ language && !blockClassName.includes(`language-${language}`),
114
+ },
115
+ ThemeClassNames.common.codeBlock,
116
+ )}>
76
117
  {codeBlockTitle && (
77
118
  <div style={style} className={styles.codeBlockTitle}>
78
119
  {codeBlockTitle}
@@ -9,12 +9,11 @@
9
9
  margin-bottom: var(--ifm-leading);
10
10
  border-radius: var(--ifm-global-radius);
11
11
  box-shadow: var(--ifm-global-shadow-lw);
12
- overflow: hidden;
13
12
  }
14
13
 
15
14
  .codeBlockContent {
16
15
  position: relative;
17
- /*rtl:ignore*/
16
+ /* rtl:ignore */
18
17
  direction: ltr;
19
18
  }
20
19
 
@@ -23,16 +22,28 @@
23
22
  font-size: var(--ifm-code-font-size);
24
23
  font-weight: 500;
25
24
  padding: 0.75rem var(--ifm-pre-padding);
25
+ border-top-left-radius: var(--ifm-global-radius);
26
+ border-top-right-radius: var(--ifm-global-radius);
26
27
  }
27
28
 
28
29
  .codeBlock {
29
30
  margin: 0;
30
31
  padding: 0;
31
- border-radius: 0;
32
+ border-radius: var(--ifm-global-radius);
33
+ }
34
+
35
+ .codeBlockTitle + .codeBlockContent .codeBlock {
36
+ border-top-left-radius: 0;
37
+ border-top-right-radius: 0;
38
+ }
39
+
40
+ .codeBlockStandalone {
41
+ padding: 0;
42
+ border-radius: var(--ifm-global-radius);
32
43
  }
33
44
 
34
45
  .copyButton {
35
- background: rgba(0, 0, 0, 0.3);
46
+ background: rgb(0 0 0 / 30%);
36
47
  border-radius: var(--ifm-global-radius);
37
48
  color: var(--ifm-color-white);
38
49
  opacity: 0;
@@ -44,15 +55,15 @@
44
55
  transition: opacity 200ms ease-in-out;
45
56
  }
46
57
 
47
- .codeBlockTitle:hover + .codeBlockContent .copyButton,
58
+ .copyButton:focus,
48
59
  .codeBlockContent:hover > .copyButton,
49
- .copyButton:focus {
60
+ .codeBlockTitle:hover + .codeBlockContent .copyButton {
50
61
  opacity: 1;
51
62
  }
52
63
 
53
64
  .codeBlockLines {
54
65
  font: inherit;
55
- /*rtl:ignore*/
66
+ /* rtl:ignore */
56
67
  float: left;
57
68
  min-width: 100%;
58
69
  padding: var(--ifm-pre-padding);
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ReactNode} from 'react';
8
+ import React, {type ReactNode} from 'react';
9
9
  import Link from '@docusaurus/Link';
10
- import {
10
+ import type {
11
11
  PropSidebarItemCategory,
12
12
  PropSidebarItemLink,
13
13
  } from '@docusaurus/plugin-content-docs';
@@ -7,14 +7,13 @@
7
7
 
8
8
  .cardContainer {
9
9
  height: 8rem;
10
-
11
10
  color: var(--ifm-color-emphasis-800);
12
11
  --ifm-link-color: var(--ifm-color-emphasis-800);
13
12
  --ifm-link-hover-color: var(--ifm-color-emphasis-800);
14
13
  --ifm-link-hover-decoration: none;
15
14
 
16
15
  /* box-shadow: var(--ifm-global-shadow-lw); */
17
- box-shadow: 0 1.5px 3px 0 rgba(0, 0, 0, 0.15);
16
+ box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
18
17
  border: 1px solid var(--ifm-color-emphasis-200);
19
18
  transition: box-shadow var(--ifm-transition-fast) ease,
20
19
  background-color var(--ifm-transition-fast) ease;
@@ -22,8 +21,9 @@
22
21
 
23
22
  .cardContainer.cardContainerLink:hover {
24
23
  /* box-shadow: var(--ifm-global-shadow-md); */
25
- box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
24
+ box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
26
25
  }
26
+
27
27
  html[data-theme='dark'] .cardContainer.cardContainerLink:hover {
28
28
  --ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
29
29
  }
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
 
10
10
  import DocCard from '@theme/DocCard';
11
- import {PropSidebarItem} from '@docusaurus/plugin-content-docs';
11
+ import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
12
12
 
13
13
  export default function DocCardList({
14
14
  items,
@@ -13,7 +13,8 @@ import DocPaginator from '@theme/DocPaginator';
13
13
  import Seo from '@theme/Seo';
14
14
  import DocVersionBanner from '@theme/DocVersionBanner';
15
15
  import DocVersionBadge from '@theme/DocVersionBadge';
16
- import {MainHeading} from '@theme/Heading';
16
+ import Heading from '@theme/Heading';
17
+ import useBaseUrl from '@docusaurus/useBaseUrl';
17
18
 
18
19
  import styles from './styles.module.css';
19
20
 
@@ -26,14 +27,17 @@ export default function DocCategoryGeneratedIndexPage({
26
27
  <Seo
27
28
  title={categoryGeneratedIndex.title}
28
29
  description={categoryGeneratedIndex.description}
30
+ keywords={categoryGeneratedIndex.keywords}
31
+ // TODO `require` this?
32
+ image={useBaseUrl(categoryGeneratedIndex.image)}
29
33
  />
30
34
  <div className={styles.generatedIndexPage}>
31
35
  <DocVersionBanner />
32
36
  <DocVersionBadge />
33
37
  <header>
34
- <MainHeading className={styles.title}>
38
+ <Heading as="h1" className={styles.title}>
35
39
  {categoryGeneratedIndex.title}
36
- </MainHeading>
40
+ </Heading>
37
41
  {categoryGeneratedIndex.description && (
38
42
  <p>{categoryGeneratedIndex.description}</p>
39
43
  )}
@@ -7,7 +7,6 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import useWindowSize from '@theme/hooks/useWindowSize';
11
10
  import DocPaginator from '@theme/DocPaginator';
12
11
  import DocVersionBanner from '@theme/DocVersionBanner';
13
12
  import DocVersionBadge from '@theme/DocVersionBadge';
@@ -16,9 +15,9 @@ import type {Props} from '@theme/DocItem';
16
15
  import DocItemFooter from '@theme/DocItemFooter';
17
16
  import TOC from '@theme/TOC';
18
17
  import TOCCollapsible from '@theme/TOCCollapsible';
19
- import {MainHeading} from '@theme/Heading';
18
+ import Heading from '@theme/Heading';
20
19
  import styles from './styles.module.css';
21
- import {ThemeClassNames} from '@docusaurus/theme-common';
20
+ import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
22
21
 
23
22
  export default function DocItem(props: Props): JSX.Element {
24
23
  const {content: DocContent} = props;
@@ -34,7 +33,7 @@ export default function DocItem(props: Props): JSX.Element {
34
33
  const {description, title} = metadata;
35
34
 
36
35
  // We only add a title if:
37
- // - user asks to hide it with frontmatter
36
+ // - user asks to hide it with front matter
38
37
  // - the markdown content does not already contain a top-level h1 heading
39
38
  const shouldAddTitle =
40
39
  !hideTitle && typeof DocContent.contentTitle === 'undefined';
@@ -76,11 +75,15 @@ export default function DocItem(props: Props): JSX.Element {
76
75
  <div
77
76
  className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
78
77
  {/*
79
- Title can be declared inside md content or declared through frontmatter and added manually
78
+ Title can be declared inside md content or declared through front matter and added manually
80
79
  To make both cases consistent, the added title is added under the same div.markdown block
81
80
  See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
82
81
  */}
83
- {shouldAddTitle && <MainHeading>{title}</MainHeading>}
82
+ {shouldAddTitle && (
83
+ <header>
84
+ <Heading as="h1">{title}</Heading>
85
+ </header>
86
+ )}
84
87
 
85
88
  <DocContent />
86
89
  </div>
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docItemContainer article > *:first-child,
9
- .docItemContainer header + * {
8
+ .docItemContainer header + *,
9
+ .docItemContainer article > *:first-child {
10
10
  margin-top: 0;
11
11
  }
12
12
 
@@ -12,7 +12,7 @@ import LastUpdated from '@theme/LastUpdated';
12
12
  import type {Props} from '@theme/DocItem';
13
13
  import EditThisPage from '@theme/EditThisPage';
14
14
  import TagsListInline, {
15
- Props as TagsListInlineProps,
15
+ type Props as TagsListInlineProps,
16
16
  } from '@theme/TagsListInline';
17
17
 
18
18
  import styles from './styles.module.css';
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ReactNode, useState, useCallback} from 'react';
8
+ import React, {type ReactNode, useState, useCallback} from 'react';
9
9
  import {MDXProvider} from '@mdx-js/react';
10
10
 
11
11
  import renderRoutes from '@docusaurus/renderRoutes';
@@ -70,9 +70,13 @@ function DocPageContent({
70
70
 
71
71
  {sidebar && (
72
72
  <aside
73
- className={clsx(styles.docSidebarContainer, {
74
- [styles.docSidebarContainerHidden]: hiddenSidebarContainer,
75
- })}
73
+ className={clsx(
74
+ ThemeClassNames.docs.docSidebarContainer,
75
+ styles.docSidebarContainer,
76
+ {
77
+ [styles.docSidebarContainerHidden]: hiddenSidebarContainer,
78
+ },
79
+ )}
76
80
  onTransitionEnd={(e) => {
77
81
  if (
78
82
  !e.currentTarget.classList.contains(styles.docSidebarContainer)
@@ -68,6 +68,7 @@
68
68
  .expandSidebarButtonIcon {
69
69
  transform: rotate(0);
70
70
  }
71
+
71
72
  html[dir='rtl'] .expandSidebarButtonIcon {
72
73
  transform: rotate(180deg);
73
74
  }
@@ -6,11 +6,11 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import Link from '@docusaurus/Link';
10
9
  import Translate, {translate} from '@docusaurus/Translate';
11
- import type {PropNavigation} from '@docusaurus/plugin-content-docs';
10
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
11
+ import type {Props} from '@theme/DocPaginator';
12
12
 
13
- function DocPaginator(props: PropNavigation): JSX.Element {
13
+ function DocPaginator(props: Props): JSX.Element {
14
14
  const {previous, next} = props;
15
15
 
16
16
  return (
@@ -23,32 +23,30 @@ function DocPaginator(props: PropNavigation): JSX.Element {
23
23
  })}>
24
24
  <div className="pagination-nav__item">
25
25
  {previous && (
26
- <Link className="pagination-nav__link" to={previous.permalink}>
27
- <div className="pagination-nav__sublabel">
26
+ <PaginatorNavLink
27
+ {...previous}
28
+ subLabel={
28
29
  <Translate
29
30
  id="theme.docs.paginator.previous"
30
31
  description="The label used to navigate to the previous doc">
31
32
  Previous
32
33
  </Translate>
33
- </div>
34
- <div className="pagination-nav__label">
35
- &laquo; {previous.title}
36
- </div>
37
- </Link>
34
+ }
35
+ />
38
36
  )}
39
37
  </div>
40
38
  <div className="pagination-nav__item pagination-nav__item--next">
41
39
  {next && (
42
- <Link className="pagination-nav__link" to={next.permalink}>
43
- <div className="pagination-nav__sublabel">
40
+ <PaginatorNavLink
41
+ {...next}
42
+ subLabel={
44
43
  <Translate
45
44
  id="theme.docs.paginator.next"
46
45
  description="The label used to navigate to the next doc">
47
46
  Next
48
47
  </Translate>
49
- </div>
50
- <div className="pagination-nav__label">{next.title} &raquo;</div>
51
- </Link>
48
+ }
49
+ />
52
50
  )}
53
51
  </div>
54
52
  </nav>
@@ -11,15 +11,15 @@ import {
11
11
  useThemeConfig,
12
12
  useAnnouncementBar,
13
13
  MobileSecondaryMenuFiller,
14
- MobileSecondaryMenuComponent,
14
+ type MobileSecondaryMenuComponent,
15
15
  ThemeClassNames,
16
16
  useScrollPosition,
17
+ useWindowSize,
17
18
  } from '@docusaurus/theme-common';
18
- import useWindowSize from '@theme/hooks/useWindowSize';
19
19
  import Logo from '@theme/Logo';
20
20
  import IconArrow from '@theme/IconArrow';
21
21
  import {translate} from '@docusaurus/Translate';
22
- import {DocSidebarItems} from '@theme/DocSidebarItem';
22
+ import DocSidebarItems from '@theme/DocSidebarItems';
23
23
  import type {Props} from '@theme/DocSidebar';
24
24
 
25
25
  import styles from './styles.module.css';
@@ -71,6 +71,7 @@
71
71
  transform: rotate(180deg);
72
72
  margin-top: 4px;
73
73
  }
74
+
74
75
  html[dir='rtl'] .collapseSidebarButtonIcon {
75
76
  transform: rotate(0);
76
77
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useEffect, memo, useMemo} from 'react';
8
+ import React, {useEffect, useMemo} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {
11
11
  isActiveSidebarItem,
@@ -14,13 +14,16 @@ import {
14
14
  useCollapsible,
15
15
  findFirstCategoryLink,
16
16
  ThemeClassNames,
17
+ useThemeConfig,
18
+ useDocSidebarItemsExpandedState,
17
19
  } from '@docusaurus/theme-common';
18
20
  import Link from '@docusaurus/Link';
19
21
  import isInternalUrl from '@docusaurus/isInternalUrl';
20
22
  import {translate} from '@docusaurus/Translate';
21
23
  import IconExternalLink from '@theme/IconExternalLink';
22
24
 
23
- import type {Props, DocSidebarItemsProps} from '@theme/DocSidebarItem';
25
+ import DocSidebarItems from '@theme/DocSidebarItems';
26
+ import type {Props} from '@theme/DocSidebarItem';
24
27
  import type {
25
28
  PropSidebarItemCategory,
26
29
  PropSidebarItemLink,
@@ -29,23 +32,6 @@ import type {
29
32
  import styles from './styles.module.css';
30
33
  import useIsBrowser from '@docusaurus/useIsBrowser';
31
34
 
32
- // Optimize sidebar at each "level"
33
- // TODO this item should probably not receive the "activePath" props
34
- // TODO this triggers whole sidebar re-renders on navigation
35
- export const DocSidebarItems = memo(
36
- ({items, ...props}: DocSidebarItemsProps): JSX.Element => (
37
- <>
38
- {items.map((item, index) => (
39
- <DocSidebarItem
40
- key={index} // sidebar is static, the index does not change
41
- item={item}
42
- {...props}
43
- />
44
- ))}
45
- </>
46
- ),
47
- );
48
-
49
35
  export default function DocSidebarItem({
50
36
  item,
51
37
  ...props
@@ -108,6 +94,7 @@ function DocSidebarItemCategory({
108
94
  onItemClick,
109
95
  activePath,
110
96
  level,
97
+ index,
111
98
  ...props
112
99
  }: Props & {item: PropSidebarItemCategory}) {
113
100
  const {items, label, collapsible, className, href} = item;
@@ -115,7 +102,7 @@ function DocSidebarItemCategory({
115
102
 
116
103
  const isActive = isActiveSidebarItem(item, activePath);
117
104
 
118
- const {collapsed, setCollapsed, toggleCollapsed} = useCollapsible({
105
+ const {collapsed, setCollapsed} = useCollapsible({
119
106
  // active categories are always initialized as expanded
120
107
  // the default (item.collapsed) is only used for non-active categories
121
108
  initialState: () => {
@@ -127,6 +114,28 @@ function DocSidebarItemCategory({
127
114
  });
128
115
 
129
116
  useAutoExpandActiveCategory({isActive, collapsed, setCollapsed});
117
+ const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
118
+ function updateCollapsed(toCollapsed: boolean = !collapsed) {
119
+ setExpandedItem(toCollapsed ? null : index);
120
+ setCollapsed(toCollapsed);
121
+ }
122
+ const {autoCollapseSidebarCategories} = useThemeConfig();
123
+ useEffect(() => {
124
+ if (
125
+ collapsible &&
126
+ expandedItem &&
127
+ expandedItem !== index &&
128
+ autoCollapseSidebarCategories
129
+ ) {
130
+ setCollapsed(true);
131
+ }
132
+ }, [
133
+ collapsible,
134
+ expandedItem,
135
+ index,
136
+ setCollapsed,
137
+ autoCollapseSidebarCategories,
138
+ ]);
130
139
 
131
140
  return (
132
141
  <li
@@ -152,16 +161,17 @@ function DocSidebarItemCategory({
152
161
  ? (e) => {
153
162
  onItemClick?.(item);
154
163
  if (href) {
155
- setCollapsed(false);
164
+ updateCollapsed(false);
156
165
  } else {
157
166
  e.preventDefault();
158
- toggleCollapsed();
167
+ updateCollapsed();
159
168
  }
160
169
  }
161
170
  : () => {
162
171
  onItemClick?.(item);
163
172
  }
164
173
  }
174
+ aria-current={isActive ? 'page' : undefined}
165
175
  href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
166
176
  {...props}>
167
177
  {label}
@@ -181,7 +191,7 @@ function DocSidebarItemCategory({
181
191
  className="clean-btn menu__caret"
182
192
  onClick={(e) => {
183
193
  e.preventDefault();
184
- toggleCollapsed();
194
+ updateCollapsed();
185
195
  }}
186
196
  />
187
197
  )}
@@ -205,6 +215,7 @@ function DocSidebarItemLink({
205
215
  onItemClick,
206
216
  activePath,
207
217
  level,
218
+ index,
208
219
  ...props
209
220
  }: Props & {item: PropSidebarItemLink}) {
210
221
  const {href, label, className} = item;
@@ -9,6 +9,7 @@
9
9
  .menuLinkText {
10
10
  cursor: initial;
11
11
  }
12
+
12
13
  .menuLinkText:hover {
13
14
  background: none;
14
15
  }
@@ -0,0 +1,32 @@
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, {memo} from 'react';
9
+ import DocSidebarItem from '@theme/DocSidebarItem';
10
+ import {DocSidebarItemsExpandedStateProvider} from '@docusaurus/theme-common';
11
+
12
+ import type {Props} from '@theme/DocSidebarItems';
13
+
14
+ // TODO this item should probably not receive the "activePath" props
15
+ // TODO this triggers whole sidebar re-renders on navigation
16
+ function DocSidebarItems({items, ...props}: Props): JSX.Element {
17
+ return (
18
+ <DocSidebarItemsExpandedStateProvider>
19
+ {items.map((item, index) => (
20
+ <DocSidebarItem
21
+ key={index} // sidebar is static, the index does not change
22
+ item={item}
23
+ index={index}
24
+ {...props}
25
+ />
26
+ ))}
27
+ </DocSidebarItemsExpandedStateProvider>
28
+ );
29
+ }
30
+
31
+ // Optimize sidebar at each "level"
32
+ export default memo(DocSidebarItems);
@@ -5,14 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .lastUpdated {
9
- margin-top: 0.2rem;
10
- font-style: italic;
11
- font-size: smaller;
12
- }
13
-
14
8
  @media (min-width: 997px) {
15
- .lastUpdated {
16
- text-align: right;
9
+ .menuLinkText {
10
+ cursor: initial;
11
+ }
12
+
13
+ .menuLinkText:hover {
14
+ background: none;
15
+ }
16
+
17
+ .menuLinkText.hasHref {
18
+ cursor: pointer;
17
19
  }
18
20
  }
@@ -5,15 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ComponentType} from 'react';
8
+ import React, {type ComponentType} from 'react';
9
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
10
  import Link from '@docusaurus/Link';
11
11
  import Translate from '@docusaurus/Translate';
12
12
  import {
13
13
  useActivePlugin,
14
14
  useDocVersionSuggestions,
15
- GlobalVersion,
16
- } from '@theme/hooks/useDocs';
15
+ type GlobalVersion,
16
+ } from '@docusaurus/plugin-content-docs/client';
17
17
  import {
18
18
  ThemeClassNames,
19
19
  useDocsPreferredVersion,