@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
@@ -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
  }
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import Link from '@docusaurus/Link';
9
8
  import Translate, {translate} from '@docusaurus/Translate';
9
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
10
10
 
11
11
  function DocPaginator(props) {
12
12
  const {previous, next} = props;
@@ -20,32 +20,30 @@ function DocPaginator(props) {
20
20
  })}>
21
21
  <div className="pagination-nav__item">
22
22
  {previous && (
23
- <Link className="pagination-nav__link" to={previous.permalink}>
24
- <div className="pagination-nav__sublabel">
23
+ <PaginatorNavLink
24
+ {...previous}
25
+ subLabel={
25
26
  <Translate
26
27
  id="theme.docs.paginator.previous"
27
28
  description="The label used to navigate to the previous doc">
28
29
  Previous
29
30
  </Translate>
30
- </div>
31
- <div className="pagination-nav__label">
32
- &laquo; {previous.title}
33
- </div>
34
- </Link>
31
+ }
32
+ />
35
33
  )}
36
34
  </div>
37
35
  <div className="pagination-nav__item pagination-nav__item--next">
38
36
  {next && (
39
- <Link className="pagination-nav__link" to={next.permalink}>
40
- <div className="pagination-nav__sublabel">
37
+ <PaginatorNavLink
38
+ {...next}
39
+ subLabel={
41
40
  <Translate
42
41
  id="theme.docs.paginator.next"
43
42
  description="The label used to navigate to the next doc">
44
43
  Next
45
44
  </Translate>
46
- </div>
47
- <div className="pagination-nav__label">{next.title} &raquo;</div>
48
- </Link>
45
+ }
46
+ />
49
47
  )}
50
48
  </div>
51
49
  </nav>
@@ -12,12 +12,12 @@ import {
12
12
  MobileSecondaryMenuFiller,
13
13
  ThemeClassNames,
14
14
  useScrollPosition,
15
+ useWindowSize,
15
16
  } from '@docusaurus/theme-common';
16
- import useWindowSize from '@theme/hooks/useWindowSize';
17
17
  import Logo from '@theme/Logo';
18
18
  import IconArrow from '@theme/IconArrow';
19
19
  import {translate} from '@docusaurus/Translate';
20
- import {DocSidebarItems} from '@theme/DocSidebarItem';
20
+ import DocSidebarItems from '@theme/DocSidebarItems';
21
21
  import styles from './styles.module.css';
22
22
 
23
23
  function useShowAnnouncementBar() {
@@ -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
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, {useEffect, memo, useMemo} from 'react';
7
+ import React, {useEffect, useMemo} from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {
10
10
  isActiveSidebarItem,
@@ -13,27 +13,16 @@ import {
13
13
  useCollapsible,
14
14
  findFirstCategoryLink,
15
15
  ThemeClassNames,
16
+ useThemeConfig,
17
+ useDocSidebarItemsExpandedState,
16
18
  } from '@docusaurus/theme-common';
17
19
  import Link from '@docusaurus/Link';
18
20
  import isInternalUrl from '@docusaurus/isInternalUrl';
19
21
  import {translate} from '@docusaurus/Translate';
20
22
  import IconExternalLink from '@theme/IconExternalLink';
23
+ import DocSidebarItems from '@theme/DocSidebarItems';
21
24
  import styles from './styles.module.css';
22
- import useIsBrowser from '@docusaurus/useIsBrowser'; // Optimize sidebar at each "level"
23
- // TODO this item should probably not receive the "activePath" props
24
- // TODO this triggers whole sidebar re-renders on navigation
25
-
26
- export const DocSidebarItems = memo(({items, ...props}) => (
27
- <>
28
- {items.map((item, index) => (
29
- <DocSidebarItem
30
- key={index} // sidebar is static, the index does not change
31
- item={item}
32
- {...props}
33
- />
34
- ))}
35
- </>
36
- ));
25
+ import useIsBrowser from '@docusaurus/useIsBrowser';
37
26
  export default function DocSidebarItem({item, ...props}) {
38
27
  switch (item.type) {
39
28
  case 'category':
@@ -85,12 +74,13 @@ function DocSidebarItemCategory({
85
74
  onItemClick,
86
75
  activePath,
87
76
  level,
77
+ index,
88
78
  ...props
89
79
  }) {
90
80
  const {items, label, collapsible, className, href} = item;
91
81
  const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
92
82
  const isActive = isActiveSidebarItem(item, activePath);
93
- const {collapsed, setCollapsed, toggleCollapsed} = useCollapsible({
83
+ const {collapsed, setCollapsed} = useCollapsible({
94
84
  // active categories are always initialized as expanded
95
85
  // the default (item.collapsed) is only used for non-active categories
96
86
  initialState: () => {
@@ -106,6 +96,30 @@ function DocSidebarItemCategory({
106
96
  collapsed,
107
97
  setCollapsed,
108
98
  });
99
+ const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
100
+
101
+ function updateCollapsed(toCollapsed = !collapsed) {
102
+ setExpandedItem(toCollapsed ? null : index);
103
+ setCollapsed(toCollapsed);
104
+ }
105
+
106
+ const {autoCollapseSidebarCategories} = useThemeConfig();
107
+ useEffect(() => {
108
+ if (
109
+ collapsible &&
110
+ expandedItem &&
111
+ expandedItem !== index &&
112
+ autoCollapseSidebarCategories
113
+ ) {
114
+ setCollapsed(true);
115
+ }
116
+ }, [
117
+ collapsible,
118
+ expandedItem,
119
+ index,
120
+ setCollapsed,
121
+ autoCollapseSidebarCategories,
122
+ ]);
109
123
  return (
110
124
  <li
111
125
  className={clsx(
@@ -131,16 +145,17 @@ function DocSidebarItemCategory({
131
145
  onItemClick?.(item);
132
146
 
133
147
  if (href) {
134
- setCollapsed(false);
148
+ updateCollapsed(false);
135
149
  } else {
136
150
  e.preventDefault();
137
- toggleCollapsed();
151
+ updateCollapsed();
138
152
  }
139
153
  }
140
154
  : () => {
141
155
  onItemClick?.(item);
142
156
  }
143
157
  }
158
+ aria-current={isActive ? 'page' : undefined}
144
159
  href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
145
160
  {...props}>
146
161
  {label}
@@ -162,7 +177,7 @@ function DocSidebarItemCategory({
162
177
  className="clean-btn menu__caret"
163
178
  onClick={(e) => {
164
179
  e.preventDefault();
165
- toggleCollapsed();
180
+ updateCollapsed();
166
181
  }}
167
182
  />
168
183
  )}
@@ -181,7 +196,14 @@ function DocSidebarItemCategory({
181
196
  );
182
197
  }
183
198
 
184
- function DocSidebarItemLink({item, onItemClick, activePath, level, ...props}) {
199
+ function DocSidebarItemLink({
200
+ item,
201
+ onItemClick,
202
+ activePath,
203
+ level,
204
+ index,
205
+ ...props
206
+ }) {
185
207
  const {href, label, className} = item;
186
208
  const isActive = isActiveSidebarItem(item, activePath);
187
209
  return (
@@ -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,28 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, {memo} from 'react';
8
+ import DocSidebarItem from '@theme/DocSidebarItem';
9
+ import {DocSidebarItemsExpandedStateProvider} from '@docusaurus/theme-common';
10
+
11
+ // TODO this item should probably not receive the "activePath" props
12
+ // TODO this triggers whole sidebar re-renders on navigation
13
+ function DocSidebarItems({items, ...props}) {
14
+ return (
15
+ <DocSidebarItemsExpandedStateProvider>
16
+ {items.map((item, index) => (
17
+ <DocSidebarItem
18
+ key={index} // sidebar is static, the index does not change
19
+ item={item}
20
+ index={index}
21
+ {...props}
22
+ />
23
+ ))}
24
+ </DocSidebarItemsExpandedStateProvider>
25
+ );
26
+ } // Optimize sidebar at each "level"
27
+
28
+ export default memo(DocSidebarItems);
@@ -9,6 +9,7 @@
9
9
  .menuLinkText {
10
10
  cursor: initial;
11
11
  }
12
+
12
13
  .menuLinkText:hover {
13
14
  background: none;
14
15
  }
@@ -8,7 +8,10 @@ import React from 'react';
8
8
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
9
9
  import Link from '@docusaurus/Link';
10
10
  import Translate from '@docusaurus/Translate';
11
- import {useActivePlugin, useDocVersionSuggestions} from '@theme/hooks/useDocs';
11
+ import {
12
+ useActivePlugin,
13
+ useDocVersionSuggestions,
14
+ } from '@docusaurus/plugin-content-docs/client';
12
15
  import {
13
16
  ThemeClassNames,
14
17
  useDocsPreferredVersion,
@@ -54,6 +54,66 @@ function FooterLogo({sources, alt, width, height}) {
54
54
  );
55
55
  }
56
56
 
57
+ function MultiColumnLinks({links}) {
58
+ return (
59
+ <>
60
+ {links.map((linkItem, i) => (
61
+ <div key={i} className="col footer__col">
62
+ <div className="footer__title">{linkItem.title}</div>
63
+ <ul className="footer__items">
64
+ {linkItem.items.map((item, key) =>
65
+ item.html ? (
66
+ <li
67
+ key={key}
68
+ className="footer__item" // Developer provided the HTML, so assume it's safe.
69
+ // eslint-disable-next-line react/no-danger
70
+ dangerouslySetInnerHTML={{
71
+ __html: item.html,
72
+ }}
73
+ />
74
+ ) : (
75
+ <li key={item.href || item.to} className="footer__item">
76
+ <FooterLink {...item} />
77
+ </li>
78
+ ),
79
+ )}
80
+ </ul>
81
+ </div>
82
+ ))}
83
+ </>
84
+ );
85
+ }
86
+
87
+ function SimpleLinks({links}) {
88
+ return (
89
+ <div className="footer__links">
90
+ {links.map((item, key) => (
91
+ <>
92
+ {item.html ? (
93
+ <span
94
+ key={key}
95
+ className="footer__link-item" // Developer provided the HTML, so assume it's safe.
96
+ // eslint-disable-next-line react/no-danger
97
+ dangerouslySetInnerHTML={{
98
+ __html: item.html,
99
+ }}
100
+ />
101
+ ) : (
102
+ <FooterLink {...item} />
103
+ )}
104
+ {links.length !== key + 1 && (
105
+ <span className="footer__link-separator">·</span>
106
+ )}
107
+ </>
108
+ ))}
109
+ </div>
110
+ );
111
+ }
112
+
113
+ function isMultiColumnFooterLinks(links) {
114
+ return 'title' in links[0];
115
+ }
116
+
57
117
  function Footer() {
58
118
  const {footer} = useThemeConfig();
59
119
  const {copyright, links = [], logo = {}} = footer || {};
@@ -71,40 +131,18 @@ function Footer() {
71
131
  className={clsx('footer', {
72
132
  'footer--dark': footer.style === 'dark',
73
133
  })}>
74
- <div className="container">
75
- {links && links.length > 0 && (
76
- <div className="row footer__links">
77
- {links.map((linkItem, i) => (
78
- <div key={i} className="col footer__col">
79
- {linkItem.title != null ? (
80
- <div className="footer__title">{linkItem.title}</div>
81
- ) : null}
82
- {linkItem.items != null &&
83
- Array.isArray(linkItem.items) &&
84
- linkItem.items.length > 0 ? (
85
- <ul className="footer__items">
86
- {linkItem.items.map((item, key) =>
87
- item.html ? (
88
- <li
89
- key={key}
90
- className="footer__item" // Developer provided the HTML, so assume it's safe.
91
- // eslint-disable-next-line react/no-danger
92
- dangerouslySetInnerHTML={{
93
- __html: item.html,
94
- }}
95
- />
96
- ) : (
97
- <li key={item.href || item.to} className="footer__item">
98
- <FooterLink {...item} />
99
- </li>
100
- ),
101
- )}
102
- </ul>
103
- ) : null}
104
- </div>
105
- ))}
106
- </div>
107
- )}
134
+ <div className="container container-fluid">
135
+ {links &&
136
+ links.length > 0 &&
137
+ (isMultiColumnFooterLinks(links) ? (
138
+ <div className="row footer__links">
139
+ <MultiColumnLinks links={links} />
140
+ </div>
141
+ ) : (
142
+ <div className="footer__links text--center">
143
+ <SimpleLinks links={links} />
144
+ </div>
145
+ ))}
108
146
  {(logo || copyright) && (
109
147
  <div className="footer__bottom text--center">
110
148
  {logo && (logo.src || logo.srcDark) && (
@@ -139,4 +177,4 @@ function Footer() {
139
177
  );
140
178
  }
141
179
 
142
- export default Footer;
180
+ 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 {
@@ -10,54 +10,50 @@ import {translate} from '@docusaurus/Translate';
10
10
  import {useThemeConfig} from '@docusaurus/theme-common';
11
11
  import './styles.css';
12
12
  import styles from './styles.module.css';
13
- // eslint-disable-next-line react/function-component-definition
14
- export const MainHeading = ({...props}) => (
15
- <header>
16
- <h1
17
- {...props}
18
- id={undefined} // h1 headings do not need an id because they don't appear in the TOC
19
- >
20
- {props.children}
21
- </h1>
22
- </header>
23
- );
24
13
 
25
- const createAnchorHeading =
26
- (Tag) =>
27
- ({id, ...props}) => {
28
- const {
29
- navbar: {hideOnScroll},
30
- } = useThemeConfig();
14
+ function AnchorHeading({as: As, id, ...props}) {
15
+ const {
16
+ navbar: {hideOnScroll},
17
+ } = useThemeConfig();
18
+
19
+ if (!id) {
20
+ return <As {...props} />;
21
+ }
31
22
 
32
- if (!id) {
33
- return <Tag {...props} />;
34
- }
23
+ return (
24
+ <As
25
+ {...props}
26
+ className={clsx('anchor', {
27
+ [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
28
+ [styles.anchorWithStickyNavbar]: !hideOnScroll,
29
+ })}
30
+ id={id}>
31
+ {props.children}
32
+ <a
33
+ className="hash-link"
34
+ href={`#${id}`}
35
+ title={translate({
36
+ id: 'theme.common.headingLinkTitle',
37
+ message: 'Direct link to heading',
38
+ description: 'Title for link to heading',
39
+ })}>
40
+ &#8203;
41
+ </a>
42
+ </As>
43
+ );
44
+ }
35
45
 
46
+ export default function Heading({as, ...props}) {
47
+ if (as === 'h1') {
36
48
  return (
37
- <Tag
49
+ <h1
38
50
  {...props}
39
- className={clsx('anchor', {
40
- [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
41
- [styles.anchorWithStickyNavbar]: !hideOnScroll,
42
- })}
43
- id={id}>
51
+ id={undefined} // h1 headings do not need an id because they don't appear in the TOC
52
+ >
44
53
  {props.children}
45
- <a
46
- aria-hidden="true"
47
- className="hash-link"
48
- href={`#${id}`}
49
- title={translate({
50
- id: 'theme.common.headingLinkTitle',
51
- message: 'Direct link to heading',
52
- description: 'Title for link to heading',
53
- })}>
54
- &#8203;
55
- </a>
56
- </Tag>
54
+ </h1>
57
55
  );
58
- };
59
-
60
- const Heading = (headingType) =>
61
- headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
56
+ }
62
57
 
63
- export default Heading;
58
+ return <AnchorHeading as={as} {...props} />;
59
+ }
@@ -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
 
@@ -13,8 +13,7 @@ import Navbar from '@theme/Navbar';
13
13
  import Footer from '@theme/Footer';
14
14
  import LayoutProviders from '@theme/LayoutProviders';
15
15
  import LayoutHead from '@theme/LayoutHead';
16
- import useKeyboardNavigation from '@theme/hooks/useKeyboardNavigation';
17
- import {ThemeClassNames} from '@docusaurus/theme-common';
16
+ import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
18
17
  import ErrorPageContent from '@theme/ErrorPageContent';
19
18
  import './styles.css';
20
19
 
@@ -22,14 +22,14 @@ import {useLocation} from '@docusaurus/router'; // Useful for SEO
22
22
 
23
23
  function AlternateLangHeaders() {
24
24
  const {
25
- i18n: {defaultLocale, locales},
25
+ i18n: {defaultLocale, localeConfigs},
26
26
  } = useDocusaurusContext();
27
27
  const alternatePageUtils = useAlternatePageUtils(); // Note: it is fine to use both "x-default" and "en" to target the same url
28
28
  // See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
29
29
 
30
30
  return (
31
31
  <Head>
32
- {locales.map((locale) => (
32
+ {Object.entries(localeConfigs).map(([locale, {htmlLang}]) => (
33
33
  <link
34
34
  key={locale}
35
35
  rel="alternate"
@@ -37,7 +37,7 @@ function AlternateLangHeaders() {
37
37
  locale,
38
38
  fullyQualified: true,
39
39
  })}
40
- hrefLang={locale}
40
+ hrefLang={htmlLang}
41
41
  />
42
42
  ))}
43
43
  <link
@@ -84,12 +84,8 @@ export default function LayoutHead(props) {
84
84
  const {metadata, image: defaultImage} = useThemeConfig();
85
85
  const {title, description, image, keywords, searchMetadata} = props;
86
86
  const faviconUrl = useBaseUrl(favicon);
87
- const pageTitle = useTitleFormatter(title); // See https://github.com/facebook/docusaurus/issues/3317#issuecomment-754661855
88
- // const htmlLang = currentLocale.split('-')[0];
89
-
90
- const htmlLang = currentLocale; // should we allow the user to override htmlLang with localeConfig?
91
-
92
- const htmlDir = localeConfigs[currentLocale].direction;
87
+ const pageTitle = useTitleFormatter(title);
88
+ const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
93
89
  return (
94
90
  <>
95
91
  <Head>
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import ThemeProvider from '@theme/ThemeProvider';
9
- import UserPreferencesProvider from '@theme/UserPreferencesProvider';
10
8
  import {
9
+ ColorModeProvider,
10
+ TabGroupChoiceProvider,
11
11
  AnnouncementBarProvider,
12
12
  DocsPreferredVersionContextProvider,
13
13
  MobileSecondaryMenuProvider,
@@ -15,9 +15,9 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  export default function LayoutProviders({children}) {
17
17
  return (
18
- <ThemeProvider>
18
+ <ColorModeProvider>
19
19
  <AnnouncementBarProvider>
20
- <UserPreferencesProvider>
20
+ <TabGroupChoiceProvider>
21
21
  <ScrollControllerProvider>
22
22
  <DocsPreferredVersionContextProvider>
23
23
  <MobileSecondaryMenuProvider>
@@ -25,8 +25,8 @@ export default function LayoutProviders({children}) {
25
25
  </MobileSecondaryMenuProvider>
26
26
  </DocsPreferredVersionContextProvider>
27
27
  </ScrollControllerProvider>
28
- </UserPreferencesProvider>
28
+ </TabGroupChoiceProvider>
29
29
  </AnnouncementBarProvider>
30
- </ThemeProvider>
30
+ </ColorModeProvider>
31
31
  );
32
32
  }
@@ -30,35 +30,22 @@ const MDXComponents = {
30
30
  return <Head {...props}>{unwrappedChildren}</Head>;
31
31
  },
32
32
  code: (props) => {
33
- const {children} = props; // For retrocompatibility purposes (pretty rare use case)
34
- // See https://github.com/facebook/docusaurus/pull/1584
35
-
36
- if (isValidElement(children)) {
37
- return children;
38
- }
39
-
40
- return !children.includes('\n') ? (
41
- <code {...props} />
42
- ) : (
43
- <CodeBlock {...props} />
33
+ const shouldBeInline = React.Children.toArray(props.children).every(
34
+ (el) => typeof el === 'string' && !el.includes('\n'),
44
35
  );
36
+ return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
45
37
  },
46
38
  a: (props) => <Link {...props} />,
47
- pre: (props) => {
48
- const {children} = props; // See comment for `code` above
49
-
50
- if (isValidElement(children) && isValidElement(children?.props?.children)) {
51
- return children.props.children;
52
- }
53
-
54
- return (
55
- <CodeBlock
56
- {...(isValidElement(children) ? children?.props : {...props})}
57
- />
58
- );
59
- },
39
+ pre: (props) => (
40
+ <CodeBlock // If this pre is created by a ``` fenced codeblock, unwrap the children
41
+ {...(isValidElement(props.children) &&
42
+ props.children.props.originalType === 'code'
43
+ ? props.children?.props
44
+ : {...props})}
45
+ />
46
+ ),
60
47
  details: (props) => {
61
- const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the Detais theme component
48
+ const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the Details theme component
62
49
 
63
50
  const summary = items.find((item) => item?.props?.mdxType === 'summary');
64
51
  const children = <>{items.filter((item) => item !== summary)}</>;
@@ -68,11 +55,11 @@ const MDXComponents = {
68
55
  </Details>
69
56
  );
70
57
  },
71
- h1: Heading('h1'),
72
- h2: Heading('h2'),
73
- h3: Heading('h3'),
74
- h4: Heading('h4'),
75
- h5: Heading('h5'),
76
- h6: Heading('h6'),
58
+ h1: (props) => <Heading as="h1" {...props} />,
59
+ h2: (props) => <Heading as="h2" {...props} />,
60
+ h3: (props) => <Heading as="h3" {...props} />,
61
+ h4: (props) => <Heading as="h4" {...props} />,
62
+ h5: (props) => <Heading as="h5" {...props} />,
63
+ h6: (props) => <Heading as="h6" {...props} />,
77
64
  };
78
65
  export default MDXComponents;