@docusaurus/theme-classic 2.0.0-beta.14 → 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 (152) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +7 -16
  3. package/lib/theme-classic.d.ts +89 -182
  4. package/lib/validateThemeConfig.js +13 -1
  5. package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
  6. package/lib-next/theme/BlogListPaginator/index.js +12 -12
  7. package/lib-next/theme/BlogPostAuthor/index.js +1 -1
  8. package/lib-next/theme/BlogPostAuthors/index.js +12 -2
  9. package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
  10. package/lib-next/theme/BlogPostItem/index.js +12 -15
  11. package/lib-next/theme/BlogPostPage/index.js +10 -7
  12. package/lib-next/theme/BlogPostPaginator/index.js +11 -15
  13. package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
  14. package/lib-next/theme/CodeBlock/index.js +44 -9
  15. package/lib-next/theme/CodeBlock/styles.module.css +12 -7
  16. package/lib-next/theme/DocCard/styles.module.css +3 -3
  17. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
  18. package/lib-next/theme/DocItem/index.js +9 -6
  19. package/lib-next/theme/DocItem/styles.module.css +2 -2
  20. package/lib-next/theme/DocPage/index.js +7 -3
  21. package/lib-next/theme/DocPage/styles.module.css +1 -0
  22. package/lib-next/theme/DocPaginator/index.js +26 -4
  23. package/lib-next/theme/DocSidebar/index.js +2 -2
  24. package/lib-next/theme/DocSidebar/styles.module.css +1 -0
  25. package/lib-next/theme/DocSidebarItem/index.js +43 -21
  26. package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
  27. package/lib-next/theme/DocSidebarItems/index.js +28 -0
  28. package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +12 -2
  29. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  30. package/lib-next/theme/Footer/styles.module.css +2 -1
  31. package/lib-next/theme/Heading/index.js +39 -42
  32. package/lib-next/theme/Heading/styles.css +1 -1
  33. package/lib-next/theme/Layout/index.js +1 -2
  34. package/lib-next/theme/LayoutHead/index.js +5 -9
  35. package/lib-next/theme/LayoutProviders/index.js +6 -6
  36. package/lib-next/theme/MDXComponents/index.js +18 -31
  37. package/lib-next/theme/MDXComponents/styles.css +4 -0
  38. package/lib-next/theme/MDXPage/index.js +3 -10
  39. package/lib-next/theme/Navbar/index.js +6 -6
  40. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  41. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  42. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
  43. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
  44. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  45. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
  46. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  47. package/lib-next/theme/NavbarItem/index.js +1 -2
  48. package/lib-next/theme/{hooks/styles.css → NavbarItem/utils.js} +3 -4
  49. package/lib-next/theme/PaginatorNavLink/index.js +20 -0
  50. package/lib-next/theme/SkipToContent/index.js +1 -1
  51. package/lib-next/theme/SkipToContent/styles.module.css +7 -0
  52. package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
  53. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  54. package/lib-next/theme/Tabs/index.js +6 -3
  55. package/lib-next/theme/Tag/styles.module.css +4 -4
  56. package/lib-next/theme/ThemedImage/index.js +2 -2
  57. package/lib-next/theme/Toggle/styles.module.css +16 -15
  58. package/lib-next/theme/prism-include-languages.js +10 -3
  59. package/package.json +16 -17
  60. package/src/index.ts +10 -21
  61. package/src/theme/Admonition/index.tsx +1 -1
  62. package/src/theme/BackToTopButton/styles.module.css +1 -1
  63. package/src/theme/BlogListPaginator/index.tsx +12 -12
  64. package/src/theme/BlogPostAuthor/index.tsx +1 -1
  65. package/src/theme/BlogPostAuthors/index.tsx +12 -2
  66. package/src/theme/BlogPostAuthors/styles.module.css +10 -0
  67. package/src/theme/BlogPostItem/index.tsx +13 -15
  68. package/src/theme/BlogPostPage/index.tsx +10 -7
  69. package/src/theme/BlogPostPaginator/index.tsx +11 -15
  70. package/src/theme/BlogSidebar/styles.module.css +2 -0
  71. package/src/theme/CodeBlock/index.tsx +45 -10
  72. package/src/theme/CodeBlock/styles.module.css +12 -7
  73. package/src/theme/DocCard/index.tsx +2 -2
  74. package/src/theme/DocCard/styles.module.css +3 -3
  75. package/src/theme/DocCardList/index.tsx +1 -1
  76. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
  77. package/src/theme/DocItem/index.tsx +9 -6
  78. package/src/theme/DocItem/styles.module.css +2 -2
  79. package/src/theme/DocItemFooter/index.tsx +1 -1
  80. package/src/theme/DocPage/index.tsx +8 -4
  81. package/src/theme/DocPage/styles.module.css +1 -0
  82. package/src/theme/DocPaginator/index.tsx +26 -4
  83. package/src/theme/DocSidebar/index.tsx +3 -3
  84. package/src/theme/DocSidebar/styles.module.css +1 -0
  85. package/src/theme/DocSidebarItem/index.tsx +34 -23
  86. package/src/theme/DocSidebarItem/styles.module.css +1 -0
  87. package/src/theme/DocSidebarItems/index.tsx +32 -0
  88. package/src/theme/{UserPreferencesContext.ts → DocSidebarItems/styles.module.css} +11 -3
  89. package/src/theme/DocVersionBanner/index.tsx +3 -3
  90. package/src/theme/Footer/index.tsx +4 -4
  91. package/src/theme/Footer/styles.module.css +2 -1
  92. package/src/theme/Heading/index.tsx +39 -46
  93. package/src/theme/Heading/styles.css +1 -1
  94. package/src/theme/Layout/index.tsx +1 -2
  95. package/src/theme/LayoutHead/index.tsx +4 -8
  96. package/src/theme/LayoutProviders/index.tsx +6 -6
  97. package/src/theme/MDXComponents/index.tsx +26 -37
  98. package/src/theme/MDXComponents/styles.css +4 -0
  99. package/src/theme/MDXPage/index.tsx +3 -11
  100. package/src/theme/Navbar/index.tsx +7 -7
  101. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  102. package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
  103. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
  104. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
  105. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
  106. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
  107. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  108. package/src/theme/NavbarItem/index.tsx +3 -5
  109. package/{lib-next/theme/UserPreferencesContext.js → src/theme/NavbarItem/utils.ts} +4 -3
  110. package/src/theme/PaginatorNavLink/index.tsx +22 -0
  111. package/src/theme/SkipToContent/index.tsx +1 -1
  112. package/src/theme/SkipToContent/styles.module.css +7 -0
  113. package/src/theme/TOCCollapsible/styles.module.css +2 -2
  114. package/src/theme/TOCItems/index.tsx +2 -2
  115. package/src/theme/Tabs/index.tsx +7 -4
  116. package/src/theme/Tag/styles.module.css +4 -4
  117. package/src/theme/TagsListByLetter/index.tsx +1 -1
  118. package/src/theme/ThemedImage/index.tsx +2 -2
  119. package/src/theme/Toggle/index.tsx +1 -1
  120. package/src/theme/Toggle/styles.module.css +16 -15
  121. package/src/theme/prism-include-languages.ts +10 -3
  122. package/src/theme-classic.d.ts +89 -182
  123. package/src/translations.ts +2 -2
  124. package/src/validateThemeConfig.ts +16 -0
  125. package/lib-next/theme/DocPaginatorNavLink/index.js +0 -36
  126. package/lib-next/theme/ThemeContext.js +0 -9
  127. package/lib-next/theme/ThemeProvider/index.js +0 -28
  128. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  129. package/lib-next/theme/hooks/useDocs.js +0 -10
  130. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  131. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  132. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  133. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  134. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  135. package/lib-next/theme/hooks/useTheme.js +0 -81
  136. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  137. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  138. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  139. package/src/theme/DocPaginatorNavLink/index.tsx +0 -38
  140. package/src/theme/ThemeContext.ts +0 -15
  141. package/src/theme/ThemeProvider/index.tsx +0 -28
  142. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  143. package/src/theme/hooks/useDocs.ts +0 -11
  144. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  145. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  146. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  147. package/src/theme/hooks/usePrismTheme.ts +0 -22
  148. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  149. package/src/theme/hooks/useTheme.ts +0 -91
  150. package/src/theme/hooks/useThemeContext.ts +0 -23
  151. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  152. package/src/theme/hooks/useWindowSize.ts +0 -69
@@ -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,8 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {createContext} from 'react';
8
+ @media (min-width: 997px) {
9
+ .menuLinkText {
10
+ cursor: initial;
11
+ }
9
12
 
10
- const UserPreferencesContext = createContext(undefined);
13
+ .menuLinkText:hover {
14
+ background: none;
15
+ }
11
16
 
12
- export default UserPreferencesContext;
17
+ .menuLinkText.hasHref {
18
+ cursor: pointer;
19
+ }
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,
@@ -10,15 +10,15 @@ import clsx from 'clsx';
10
10
 
11
11
  import Link from '@docusaurus/Link';
12
12
  import {
13
- FooterLinkItem,
13
+ type FooterLinkItem,
14
14
  useThemeConfig,
15
- MultiColumnFooter,
16
- SimpleFooter,
15
+ type MultiColumnFooter,
16
+ type SimpleFooter,
17
17
  } from '@docusaurus/theme-common';
18
18
  import useBaseUrl from '@docusaurus/useBaseUrl';
19
19
  import isInternalUrl from '@docusaurus/isInternalUrl';
20
20
  import styles from './styles.module.css';
21
- import ThemedImage, {Props as ThemedImageProps} from '@theme/ThemedImage';
21
+ import ThemedImage, {type Props as ThemedImageProps} from '@theme/ThemedImage';
22
22
  import IconExternalLink from '@theme/IconExternalLink';
23
23
 
24
24
  function FooterLink({
@@ -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,62 +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
- className="hash-link"
53
- href={`#${id}`}
54
- title={translate({
55
- id: 'theme.common.headingLinkTitle',
56
- message: 'Direct link to heading',
57
- description: 'Title for link to heading',
58
- })}>
59
- &#8203;
60
- </a>
61
- </Tag>
57
+ </h1>
62
58
  );
63
- };
64
-
65
- const Heading = (headingType: HeadingType): ((props: Props) => JSX.Element) =>
66
- headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
67
-
68
- 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],