@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
@@ -9,11 +9,16 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
 
11
11
  import Link from '@docusaurus/Link';
12
- import {FooterLinkItem, useThemeConfig} from '@docusaurus/theme-common';
12
+ import {
13
+ type FooterLinkItem,
14
+ useThemeConfig,
15
+ type MultiColumnFooter,
16
+ type SimpleFooter,
17
+ } from '@docusaurus/theme-common';
13
18
  import useBaseUrl from '@docusaurus/useBaseUrl';
14
19
  import isInternalUrl from '@docusaurus/isInternalUrl';
15
20
  import styles from './styles.module.css';
16
- import ThemedImage, {Props as ThemedImageProps} from '@theme/ThemedImage';
21
+ import ThemedImage, {type Props as ThemedImageProps} from '@theme/ThemedImage';
17
22
  import IconExternalLink from '@theme/IconExternalLink';
18
23
 
19
24
  function FooterLink({
@@ -66,6 +71,70 @@ function FooterLogo({
66
71
  );
67
72
  }
68
73
 
74
+ function MultiColumnLinks({links}: {links: MultiColumnFooter['links']}) {
75
+ return (
76
+ <>
77
+ {links.map((linkItem, i) => (
78
+ <div key={i} className="col footer__col">
79
+ <div className="footer__title">{linkItem.title}</div>
80
+ <ul className="footer__items">
81
+ {linkItem.items.map((item, key) =>
82
+ item.html ? (
83
+ <li
84
+ key={key}
85
+ className="footer__item"
86
+ // Developer provided the HTML, so assume it's safe.
87
+ // eslint-disable-next-line react/no-danger
88
+ dangerouslySetInnerHTML={{
89
+ __html: item.html,
90
+ }}
91
+ />
92
+ ) : (
93
+ <li key={item.href || item.to} className="footer__item">
94
+ <FooterLink {...item} />
95
+ </li>
96
+ ),
97
+ )}
98
+ </ul>
99
+ </div>
100
+ ))}
101
+ </>
102
+ );
103
+ }
104
+
105
+ function SimpleLinks({links}: {links: SimpleFooter['links']}) {
106
+ return (
107
+ <div className="footer__links">
108
+ {links.map((item, key) => (
109
+ <>
110
+ {item.html ? (
111
+ <span
112
+ key={key}
113
+ className="footer__link-item"
114
+ // Developer provided the HTML, so assume it's safe.
115
+ // eslint-disable-next-line react/no-danger
116
+ dangerouslySetInnerHTML={{
117
+ __html: item.html,
118
+ }}
119
+ />
120
+ ) : (
121
+ <FooterLink {...item} />
122
+ )}
123
+ {links.length !== key + 1 && (
124
+ <span className="footer__link-separator">·</span>
125
+ )}
126
+ </>
127
+ ))}
128
+ </div>
129
+ );
130
+ }
131
+
132
+ function isMultiColumnFooterLinks(
133
+ links: MultiColumnFooter['links'] | SimpleFooter['links'],
134
+ ): links is MultiColumnFooter['links'] {
135
+ return 'title' in links[0];
136
+ }
137
+
69
138
  function Footer(): JSX.Element | null {
70
139
  const {footer} = useThemeConfig();
71
140
 
@@ -84,41 +153,18 @@ function Footer(): JSX.Element | null {
84
153
  className={clsx('footer', {
85
154
  'footer--dark': footer.style === 'dark',
86
155
  })}>
87
- <div className="container">
88
- {links && links.length > 0 && (
89
- <div className="row footer__links">
90
- {links.map((linkItem, i) => (
91
- <div key={i} className="col footer__col">
92
- {linkItem.title != null ? (
93
- <div className="footer__title">{linkItem.title}</div>
94
- ) : null}
95
- {linkItem.items != null &&
96
- Array.isArray(linkItem.items) &&
97
- linkItem.items.length > 0 ? (
98
- <ul className="footer__items">
99
- {linkItem.items.map((item, key) =>
100
- item.html ? (
101
- <li
102
- key={key}
103
- className="footer__item"
104
- // Developer provided the HTML, so assume it's safe.
105
- // eslint-disable-next-line react/no-danger
106
- dangerouslySetInnerHTML={{
107
- __html: item.html,
108
- }}
109
- />
110
- ) : (
111
- <li key={item.href || item.to} className="footer__item">
112
- <FooterLink {...item} />
113
- </li>
114
- ),
115
- )}
116
- </ul>
117
- ) : null}
118
- </div>
119
- ))}
120
- </div>
121
- )}
156
+ <div className="container container-fluid">
157
+ {links &&
158
+ links.length > 0 &&
159
+ (isMultiColumnFooterLinks(links) ? (
160
+ <div className="row footer__links">
161
+ <MultiColumnLinks links={links} />
162
+ </div>
163
+ ) : (
164
+ <div className="footer__links text--center">
165
+ <SimpleLinks links={links} />
166
+ </div>
167
+ ))}
122
168
  {(logo || copyright) && (
123
169
  <div className="footer__bottom text--center">
124
170
  {logo && (logo.src || logo.srcDark) && (
@@ -154,4 +200,4 @@ function Footer(): JSX.Element | null {
154
200
  );
155
201
  }
156
202
 
157
- export default Footer;
203
+ export default React.memo(Footer);
@@ -7,7 +7,8 @@
7
7
 
8
8
  .footerLogoLink {
9
9
  opacity: 0.5;
10
- transition: opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default);
10
+ transition: opacity var(--ifm-transition-fast)
11
+ var(--ifm-transition-timing-default);
11
12
  }
12
13
 
13
14
  .footerLogoLink:hover {
@@ -7,63 +7,55 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import type {HeadingType, Props} from '@theme/Heading';
10
+ import type {Props} from '@theme/Heading';
11
11
  import {translate} from '@docusaurus/Translate';
12
12
  import {useThemeConfig} from '@docusaurus/theme-common';
13
13
 
14
14
  import './styles.css';
15
15
  import styles from './styles.module.css';
16
16
 
17
- type HeadingComponent = (props: Props) => JSX.Element;
17
+ function AnchorHeading({as: As, id, ...props}: Props) {
18
+ const {
19
+ navbar: {hideOnScroll},
20
+ } = useThemeConfig();
18
21
 
19
- // eslint-disable-next-line react/function-component-definition
20
- export const MainHeading: HeadingComponent = ({...props}) => (
21
- <header>
22
- <h1
22
+ if (!id) {
23
+ return <As {...props} />;
24
+ }
25
+
26
+ return (
27
+ <As
23
28
  {...props}
24
- id={undefined} // h1 headings do not need an id because they don't appear in the TOC
25
- >
29
+ className={clsx('anchor', {
30
+ [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
31
+ [styles.anchorWithStickyNavbar]: !hideOnScroll,
32
+ })}
33
+ id={id}>
26
34
  {props.children}
27
- </h1>
28
- </header>
29
- );
30
-
31
- const createAnchorHeading =
32
- (Tag: HeadingType) =>
33
- ({id, ...props}: Props) => {
34
- const {
35
- navbar: {hideOnScroll},
36
- } = useThemeConfig();
37
-
38
- if (!id) {
39
- return <Tag {...props} />;
40
- }
41
-
35
+ <a
36
+ className="hash-link"
37
+ href={`#${id}`}
38
+ title={translate({
39
+ id: 'theme.common.headingLinkTitle',
40
+ message: 'Direct link to heading',
41
+ description: 'Title for link to heading',
42
+ })}>
43
+ &#8203;
44
+ </a>
45
+ </As>
46
+ );
47
+ }
48
+
49
+ export default function Heading({as, ...props}: Props): JSX.Element {
50
+ if (as === 'h1') {
42
51
  return (
43
- <Tag
52
+ <h1
44
53
  {...props}
45
- className={clsx('anchor', {
46
- [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
47
- [styles.anchorWithStickyNavbar]: !hideOnScroll,
48
- })}
49
- id={id}>
54
+ id={undefined} // h1 headings do not need an id because they don't appear in the TOC
55
+ >
50
56
  {props.children}
51
- <a
52
- aria-hidden="true"
53
- className="hash-link"
54
- href={`#${id}`}
55
- title={translate({
56
- id: 'theme.common.headingLinkTitle',
57
- message: 'Direct link to heading',
58
- description: 'Title for link to heading',
59
- })}>
60
- &#8203;
61
- </a>
62
- </Tag>
57
+ </h1>
63
58
  );
64
- };
65
-
66
- const Heading = (headingType: HeadingType): ((props: Props) => JSX.Element) =>
67
- headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
68
-
69
- export default Heading;
59
+ }
60
+ return <AnchorHeading as={as} {...props} />;
61
+ }
@@ -12,7 +12,7 @@
12
12
  user-select: none;
13
13
  }
14
14
 
15
- .hash-link:before {
15
+ .hash-link::before {
16
16
  content: '#';
17
17
  }
18
18
 
@@ -15,8 +15,7 @@ import Footer from '@theme/Footer';
15
15
  import LayoutProviders from '@theme/LayoutProviders';
16
16
  import LayoutHead from '@theme/LayoutHead';
17
17
  import type {Props} from '@theme/Layout';
18
- import useKeyboardNavigation from '@theme/hooks/useKeyboardNavigation';
19
- import {ThemeClassNames} from '@docusaurus/theme-common';
18
+ import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
20
19
  import ErrorPageContent from '@theme/ErrorPageContent';
21
20
  import './styles.css';
22
21
 
@@ -25,7 +25,7 @@ import {useLocation} from '@docusaurus/router';
25
25
  // See https://github.com/facebook/docusaurus/issues/3317
26
26
  function AlternateLangHeaders(): JSX.Element {
27
27
  const {
28
- i18n: {defaultLocale, locales},
28
+ i18n: {defaultLocale, localeConfigs},
29
29
  } = useDocusaurusContext();
30
30
  const alternatePageUtils = useAlternatePageUtils();
31
31
 
@@ -33,7 +33,7 @@ function AlternateLangHeaders(): JSX.Element {
33
33
  // See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
34
34
  return (
35
35
  <Head>
36
- {locales.map((locale) => (
36
+ {Object.entries(localeConfigs).map(([locale, {htmlLang}]) => (
37
37
  <link
38
38
  key={locale}
39
39
  rel="alternate"
@@ -41,7 +41,7 @@ function AlternateLangHeaders(): JSX.Element {
41
41
  locale,
42
42
  fullyQualified: true,
43
43
  })}
44
- hrefLang={locale}
44
+ hrefLang={htmlLang}
45
45
  />
46
46
  ))}
47
47
  <link
@@ -91,11 +91,7 @@ export default function LayoutHead(props: Props): JSX.Element {
91
91
  const {title, description, image, keywords, searchMetadata} = props;
92
92
  const faviconUrl = useBaseUrl(favicon);
93
93
  const pageTitle = useTitleFormatter(title);
94
-
95
- // See https://github.com/facebook/docusaurus/issues/3317#issuecomment-754661855
96
- // const htmlLang = currentLocale.split('-')[0];
97
- const htmlLang = currentLocale; // should we allow the user to override htmlLang with localeConfig?
98
- const htmlDir = localeConfigs[currentLocale].direction;
94
+ const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
99
95
 
100
96
  return (
101
97
  <>
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import ThemeProvider from '@theme/ThemeProvider';
10
- import UserPreferencesProvider from '@theme/UserPreferencesProvider';
11
9
  import {
10
+ ColorModeProvider,
11
+ TabGroupChoiceProvider,
12
12
  AnnouncementBarProvider,
13
13
  DocsPreferredVersionContextProvider,
14
14
  MobileSecondaryMenuProvider,
@@ -18,9 +18,9 @@ import type {Props} from '@theme/LayoutProviders';
18
18
 
19
19
  export default function LayoutProviders({children}: Props): JSX.Element {
20
20
  return (
21
- <ThemeProvider>
21
+ <ColorModeProvider>
22
22
  <AnnouncementBarProvider>
23
- <UserPreferencesProvider>
23
+ <TabGroupChoiceProvider>
24
24
  <ScrollControllerProvider>
25
25
  <DocsPreferredVersionContextProvider>
26
26
  <MobileSecondaryMenuProvider>
@@ -28,8 +28,8 @@ export default function LayoutProviders({children}: Props): JSX.Element {
28
28
  </MobileSecondaryMenuProvider>
29
29
  </DocsPreferredVersionContextProvider>
30
30
  </ScrollControllerProvider>
31
- </UserPreferencesProvider>
31
+ </TabGroupChoiceProvider>
32
32
  </AnnouncementBarProvider>
33
- </ThemeProvider>
33
+ </ColorModeProvider>
34
34
  );
35
35
  }
@@ -5,10 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ComponentProps, isValidElement, ReactElement} from 'react';
8
+ import React, {
9
+ type ComponentProps,
10
+ isValidElement,
11
+ type ReactElement,
12
+ } from 'react';
9
13
  import Head from '@docusaurus/Head';
10
14
  import Link from '@docusaurus/Link';
11
- import CodeBlock, {Props} from '@theme/CodeBlock';
15
+ import CodeBlock from '@theme/CodeBlock';
12
16
  import Heading from '@theme/Heading';
13
17
  import Details from '@theme/Details';
14
18
  import type {MDXComponentsObject} from '@theme/MDXComponents';
@@ -33,40 +37,25 @@ const MDXComponents: MDXComponentsObject = {
33
37
  return <Head {...props}>{unwrappedChildren}</Head>;
34
38
  },
35
39
  code: (props) => {
36
- const {children} = props;
37
-
38
- // For retrocompatibility purposes (pretty rare use case)
39
- // See https://github.com/facebook/docusaurus/pull/1584
40
- if (isValidElement(children)) {
41
- return children;
42
- }
43
-
44
- return !children.includes('\n') ? (
45
- <code {...props} />
46
- ) : (
47
- <CodeBlock {...props} />
40
+ const shouldBeInline = React.Children.toArray(props.children).every(
41
+ (el) => typeof el === 'string' && !el.includes('\n'),
48
42
  );
49
- },
50
- a: (props) => <Link {...props} />,
51
- pre: (props) => {
52
- const {children} = props;
53
43
 
54
- // See comment for `code` above
55
- if (isValidElement(children) && isValidElement(children?.props?.children)) {
56
- return children.props.children;
57
- }
58
-
59
- return (
60
- <CodeBlock
61
- {...((isValidElement(children)
62
- ? children?.props
63
- : {...props}) as Props)}
64
- />
65
- );
44
+ return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
66
45
  },
46
+ a: (props) => <Link {...props} />,
47
+ pre: (props) => (
48
+ <CodeBlock
49
+ // If this pre is created by a ``` fenced codeblock, unwrap the children
50
+ {...(isValidElement(props.children) &&
51
+ props.children.props.originalType === 'code'
52
+ ? props.children?.props
53
+ : {...props})}
54
+ />
55
+ ),
67
56
  details: (props): JSX.Element => {
68
57
  const items = React.Children.toArray(props.children) as ReactElement[];
69
- // Split summary item from the rest to pass it as a separate prop to the Detais theme component
58
+ // Split summary item from the rest to pass it as a separate prop to the Details theme component
70
59
  const summary: ReactElement<ComponentProps<'summary'>> = items.find(
71
60
  (item) => item?.props?.mdxType === 'summary',
72
61
  )!;
@@ -78,12 +67,12 @@ const MDXComponents: MDXComponentsObject = {
78
67
  </Details>
79
68
  );
80
69
  },
81
- h1: Heading('h1'),
82
- h2: Heading('h2'),
83
- h3: Heading('h3'),
84
- h4: Heading('h4'),
85
- h5: Heading('h5'),
86
- h6: Heading('h6'),
70
+ h1: (props) => <Heading as="h1" {...props} />,
71
+ h2: (props) => <Heading as="h2" {...props} />,
72
+ h3: (props) => <Heading as="h3" {...props} />,
73
+ h4: (props) => <Heading as="h4" {...props} />,
74
+ h5: (props) => <Heading as="h5" {...props} />,
75
+ h6: (props) => <Heading as="h6" {...props} />,
87
76
  };
88
77
 
89
78
  export default MDXComponents;
@@ -9,3 +9,7 @@ ul.contains-task-list {
9
9
  padding-left: 0;
10
10
  list-style: none;
11
11
  }
12
+
13
+ img {
14
+ height: auto;
15
+ }
@@ -19,18 +19,10 @@ import styles from './styles.module.css';
19
19
  function MDXPage(props: Props): JSX.Element {
20
20
  const {content: MDXPageContent} = props;
21
21
  const {
22
- // TODO this frontmatter is not validated/normalized, it's the raw user-provided one. We should expose normalized one too!
23
- frontMatter,
24
- metadata,
22
+ metadata: {title, description, permalink, frontMatter},
25
23
  } = MDXPageContent;
26
-
27
- const {
28
- title,
29
- description,
30
- wrapperClassName,
31
- hide_table_of_contents: hideTableOfContents,
32
- } = frontMatter;
33
- const {permalink} = metadata;
24
+ const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
25
+ frontMatter;
34
26
 
35
27
  return (
36
28
  <Layout
@@ -10,18 +10,18 @@ import clsx from 'clsx';
10
10
  import Translate from '@docusaurus/Translate';
11
11
  import SearchBar from '@theme/SearchBar';
12
12
  import Toggle from '@theme/Toggle';
13
- import useThemeContext from '@theme/hooks/useThemeContext';
14
13
  import {
15
14
  useThemeConfig,
16
15
  useMobileSecondaryMenuRenderer,
17
16
  usePrevious,
18
17
  useHistoryPopHandler,
18
+ useHideableNavbar,
19
+ useLockBodyScroll,
20
+ useWindowSize,
21
+ useColorMode,
19
22
  } from '@docusaurus/theme-common';
20
- import useHideableNavbar from '@theme/hooks/useHideableNavbar';
21
- import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
22
- import useWindowSize from '@theme/hooks/useWindowSize';
23
- import {useActivePlugin} from '@theme/hooks/useDocs';
24
- import NavbarItem, {Props as NavbarItemConfig} from '@theme/NavbarItem';
23
+ import {useActivePlugin} from '@docusaurus/plugin-content-docs/client';
24
+ import NavbarItem, {type Props as NavbarItemConfig} from '@theme/NavbarItem';
25
25
  import Logo from '@theme/Logo';
26
26
  import IconMenu from '@theme/IconMenu';
27
27
  import IconClose from '@theme/IconClose';
@@ -88,7 +88,7 @@ function useColorModeToggle() {
88
88
  const {
89
89
  colorMode: {disableSwitch},
90
90
  } = useThemeConfig();
91
- const {isDarkTheme, setLightTheme, setDarkTheme} = useThemeContext();
91
+ const {isDarkTheme, setLightTheme, setDarkTheme} = useColorMode();
92
92
  const toggle = useCallback(
93
93
  (e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
94
94
  [setLightTheme, setDarkTheme],
@@ -7,71 +7,15 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import Link from '@docusaurus/Link';
11
- import useBaseUrl from '@docusaurus/useBaseUrl';
10
+
11
+ import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
12
+
12
13
  import type {
13
- NavLinkProps,
14
14
  DesktopOrMobileNavBarItemProps,
15
15
  Props,
16
16
  } from '@theme/NavbarItem/DefaultNavbarItem';
17
- import IconExternalLink from '@theme/IconExternalLink';
18
- import isInternalUrl from '@docusaurus/isInternalUrl';
19
- import {isRegexpStringMatch} from '@docusaurus/theme-common';
20
- import {getInfimaActiveClassName} from './index';
21
-
22
- const dropdownLinkActiveClass = 'dropdown__link--active';
23
-
24
- export function NavLink({
25
- activeBasePath,
26
- activeBaseRegex,
27
- to,
28
- href,
29
- label,
30
- activeClassName = '',
31
- prependBaseUrlToHref,
32
- ...props
33
- }: NavLinkProps): JSX.Element {
34
- // TODO all this seems hacky
35
- // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
36
- const toUrl = useBaseUrl(to);
37
- const activeBaseUrl = useBaseUrl(activeBasePath);
38
- const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
39
- const isExternalLink = label && href && !isInternalUrl(href);
40
- const isDropdownLink = activeClassName === dropdownLinkActiveClass;
41
17
 
42
- return (
43
- <Link
44
- {...(href
45
- ? {
46
- href: prependBaseUrlToHref ? normalizedHref : href,
47
- }
48
- : {
49
- isNavLink: true,
50
- activeClassName: !props.className?.includes(activeClassName)
51
- ? activeClassName
52
- : '',
53
- to: toUrl,
54
- ...(activeBasePath || activeBaseRegex
55
- ? {
56
- isActive: (_match, location) =>
57
- activeBaseRegex
58
- ? isRegexpStringMatch(activeBaseRegex, location.pathname)
59
- : location.pathname.startsWith(activeBaseUrl),
60
- }
61
- : null),
62
- })}
63
- {...props}>
64
- {isExternalLink ? (
65
- <span>
66
- {label}
67
- <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
68
- </span>
69
- ) : (
70
- label
71
- )}
72
- </Link>
73
- );
74
- }
18
+ import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
75
19
 
76
20
  function DefaultNavbarItemDesktop({
77
21
  className,
@@ -79,7 +23,7 @@ function DefaultNavbarItemDesktop({
79
23
  ...props
80
24
  }: DesktopOrMobileNavBarItemProps) {
81
25
  const element = (
82
- <NavLink
26
+ <NavbarNavLink
83
27
  className={clsx(
84
28
  isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
85
29
  className,
@@ -102,7 +46,7 @@ function DefaultNavbarItemMobile({
102
46
  }: DesktopOrMobileNavBarItemProps) {
103
47
  return (
104
48
  <li className="menu__list-item">
105
- <NavLink className={clsx('menu__link', className)} {...props} />
49
+ <NavbarNavLink className={clsx('menu__link', className)} {...props} />
106
50
  </li>
107
51
  );
108
52
  }
@@ -7,14 +7,17 @@
7
7
 
8
8
  import React from 'react';
9
9
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
- import {useLatestVersion, useActiveDocContext} from '@theme/hooks/useDocs';
10
+ import {
11
+ useLatestVersion,
12
+ useActiveDocContext,
13
+ } from '@docusaurus/plugin-content-docs/client';
11
14
  import clsx from 'clsx';
12
- import {getInfimaActiveClassName} from './index';
15
+ import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
13
16
  import type {Props} from '@theme/NavbarItem/DocNavbarItem';
14
17
  import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
15
- import type {GlobalDataVersion} from '@docusaurus/plugin-content-docs';
18
+ import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
16
19
 
17
- function getDocInVersions(versions: GlobalDataVersion[], docId: string) {
20
+ function getDocInVersions(versions: GlobalVersion[], docId: string) {
18
21
  const allDocs = versions.flatMap((version) => version.docs);
19
22
  const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
20
23
  if (!doc) {
@@ -43,7 +46,7 @@ export default function DocNavbarItem({
43
46
  const versions = uniq(
44
47
  [activeVersion, preferredVersion, latestVersion].filter(
45
48
  Boolean,
46
- ) as GlobalDataVersion[],
49
+ ) as GlobalVersion[],
47
50
  );
48
51
  const doc = getDocInVersions(versions, docId);
49
52
  const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);