@docusaurus/theme-classic 2.0.0-beta.18 → 2.0.0-beta.19

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 (204) hide show
  1. package/lib/admonitions.css +4 -0
  2. package/lib/default.css +3038 -0
  3. package/lib/getSwizzleConfig.js +9 -2
  4. package/lib/index.js +4 -4
  5. package/lib/nprogress.css +41 -0
  6. package/lib/nprogress.js +46 -0
  7. package/lib/theme-classic.d.ts +315 -33
  8. package/lib/validateThemeConfig.js +72 -14
  9. package/lib-next/theme/BackToTopButton/index.js +6 -102
  10. package/lib-next/theme/BlogLayout/index.js +1 -5
  11. package/lib-next/theme/BlogListPaginator/index.js +25 -28
  12. package/lib-next/theme/BlogPostAuthor/index.js +3 -6
  13. package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
  14. package/lib-next/theme/BlogPostPaginator/index.js +25 -28
  15. package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
  16. package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
  17. package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
  18. package/lib-next/theme/BlogSidebar/index.js +11 -31
  19. package/lib-next/theme/BlogTagsListPage/index.js +2 -3
  20. package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
  21. package/lib-next/theme/CodeBlock/Container/index.js +29 -0
  22. package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
  23. package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
  24. package/lib-next/theme/CodeBlock/Content/String.js +104 -0
  25. package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
  26. package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
  27. package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
  28. package/lib-next/theme/CodeBlock/Line/index.js +49 -0
  29. package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
  30. package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
  31. package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
  32. package/lib-next/theme/CodeBlock/index.js +27 -133
  33. package/lib-next/theme/Details/index.js +1 -1
  34. package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
  35. package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
  36. package/lib-next/theme/DocCardList/index.js +6 -4
  37. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
  38. package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
  39. package/lib-next/theme/DocItem/index.js +1 -1
  40. package/lib-next/theme/DocItem/styles.module.css +6 -0
  41. package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
  42. package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
  43. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
  44. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
  45. package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
  46. package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  47. package/lib-next/theme/DocPage/Layout/index.js +34 -0
  48. package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
  49. package/lib-next/theme/DocPage/index.js +28 -146
  50. package/lib-next/theme/DocPaginator/index.js +25 -28
  51. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
  52. package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
  53. package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
  54. package/lib-next/theme/DocSidebarItem/Category.js +197 -0
  55. package/lib-next/theme/DocSidebarItem/Html.js +27 -0
  56. package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
  57. package/lib-next/theme/DocSidebarItem/Link.js +53 -0
  58. package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
  59. package/lib-next/theme/DocSidebarItem/index.js +4 -246
  60. package/lib-next/theme/DocSidebarItems/index.js +1 -6
  61. package/lib-next/theme/DocTagDocListPage/index.js +3 -3
  62. package/lib-next/theme/DocVersionBanner/index.js +2 -2
  63. package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
  64. package/lib-next/theme/Heading/index.js +4 -20
  65. package/lib-next/theme/IconHome/index.js +17 -0
  66. package/lib-next/theme/LastUpdated/index.js +1 -0
  67. package/lib-next/theme/Layout/index.js +1 -1
  68. package/lib-next/theme/MDXComponents/Ul.js +2 -4
  69. package/lib-next/theme/Navbar/Content/index.js +6 -1
  70. package/lib-next/theme/Navbar/Logo/index.js +1 -1
  71. package/lib-next/theme/Navbar/Search/index.js +11 -0
  72. package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
  73. package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
  74. package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
  75. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
  76. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
  77. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
  78. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
  79. package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
  80. package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
  81. package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
  82. package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
  83. package/lib-next/theme/NavbarItem/index.js +4 -23
  84. package/lib-next/theme/NavbarItem/utils.js +2 -1
  85. package/lib-next/theme/PaginatorNavLink/index.js +8 -2
  86. package/lib-next/theme/SiteMetadata/index.js +8 -7
  87. package/lib-next/theme/SkipToContent/index.js +3 -29
  88. package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
  89. package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
  90. package/lib-next/theme/TOCCollapsible/index.js +3 -13
  91. package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
  92. package/lib-next/theme/TOCItems/Tree.js +40 -0
  93. package/lib-next/theme/TOCItems/index.js +3 -34
  94. package/lib-next/theme/TabItem/index.js +3 -1
  95. package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
  96. package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
  97. package/lib-next/theme/Tabs/index.js +3 -3
  98. package/lib-next/theme/Tabs/styles.module.css +4 -0
  99. package/lib-next/theme/Tag/index.js +2 -3
  100. package/lib-next/theme/TagsListInline/index.js +1 -1
  101. package/package.json +23 -18
  102. package/src/admonitions.css +4 -0
  103. package/src/getSwizzleConfig.ts +10 -2
  104. package/src/index.ts +4 -3
  105. package/src/nprogress.css +41 -0
  106. package/src/nprogress.ts +31 -0
  107. package/src/theme/BackToTopButton/index.tsx +5 -112
  108. package/src/theme/BlogLayout/index.tsx +1 -5
  109. package/src/theme/BlogListPaginator/index.tsx +25 -28
  110. package/src/theme/BlogPostAuthor/index.tsx +3 -7
  111. package/src/theme/BlogPostItem/styles.module.css +9 -0
  112. package/src/theme/BlogPostPaginator/index.tsx +25 -28
  113. package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
  114. package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
  115. package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
  116. package/src/theme/BlogSidebar/index.tsx +10 -31
  117. package/src/theme/BlogTagsListPage/index.tsx +2 -3
  118. package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
  119. package/src/theme/CodeBlock/Container/index.tsx +35 -0
  120. package/src/theme/CodeBlock/Container/styles.module.css +14 -0
  121. package/src/theme/CodeBlock/Content/Element.tsx +30 -0
  122. package/src/theme/CodeBlock/Content/String.tsx +111 -0
  123. package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
  124. package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
  125. package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
  126. package/src/theme/CodeBlock/Line/index.tsx +48 -0
  127. package/src/theme/CodeBlock/Line/styles.module.css +51 -0
  128. package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
  129. package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
  130. package/src/theme/CodeBlock/index.tsx +29 -133
  131. package/src/theme/Details/index.tsx +1 -1
  132. package/src/theme/DocBreadcrumbs/index.tsx +50 -20
  133. package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
  134. package/src/theme/DocCardList/index.tsx +5 -7
  135. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
  136. package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
  137. package/src/theme/DocItem/index.tsx +1 -1
  138. package/src/theme/DocItem/styles.module.css +6 -0
  139. package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
  140. package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
  141. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
  142. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
  143. package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  144. package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
  145. package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
  146. package/src/theme/DocPage/Layout/index.tsx +39 -0
  147. package/src/theme/DocPage/index.tsx +28 -157
  148. package/src/theme/DocPaginator/index.tsx +25 -28
  149. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
  150. package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
  151. package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
  152. package/src/theme/DocSidebarItem/Category.tsx +210 -0
  153. package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
  154. package/src/theme/DocSidebarItem/Html.tsx +34 -0
  155. package/src/theme/DocSidebarItem/Link.module.css +10 -0
  156. package/src/theme/DocSidebarItem/Link.tsx +58 -0
  157. package/src/theme/DocSidebarItem/index.tsx +4 -259
  158. package/src/theme/DocSidebarItems/index.tsx +1 -6
  159. package/src/theme/DocTagDocListPage/index.tsx +3 -4
  160. package/src/theme/DocVersionBanner/index.tsx +2 -2
  161. package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
  162. package/src/theme/Heading/index.tsx +4 -18
  163. package/src/theme/IconHome/index.tsx +20 -0
  164. package/src/theme/LastUpdated/index.tsx +1 -0
  165. package/src/theme/Layout/index.tsx +1 -1
  166. package/src/theme/MDXComponents/Details.tsx +2 -3
  167. package/src/theme/MDXComponents/Ul.tsx +2 -6
  168. package/src/theme/Navbar/Content/index.tsx +6 -1
  169. package/src/theme/Navbar/Logo/index.tsx +1 -1
  170. package/src/theme/Navbar/Search/index.tsx +15 -0
  171. package/src/theme/Navbar/Search/styles.module.css +20 -0
  172. package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
  173. package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
  174. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
  175. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
  176. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
  177. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
  178. package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
  179. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
  180. package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
  181. package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
  182. package/src/theme/NavbarItem/index.tsx +9 -38
  183. package/src/theme/NavbarItem/utils.ts +5 -2
  184. package/src/theme/PaginatorNavLink/index.tsx +8 -2
  185. package/src/theme/SiteMetadata/index.tsx +8 -8
  186. package/src/theme/SkipToContent/index.tsx +3 -29
  187. package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
  188. package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
  189. package/src/theme/TOCCollapsible/index.module.css +31 -0
  190. package/src/theme/TOCCollapsible/index.tsx +3 -14
  191. package/src/theme/TOCItems/Tree.tsx +46 -0
  192. package/src/theme/TOCItems/index.tsx +2 -41
  193. package/src/theme/TabItem/index.tsx +7 -1
  194. package/src/theme/TabItem/styles.module.css +10 -0
  195. package/src/theme/Tabs/index.tsx +3 -3
  196. package/src/theme/Tabs/styles.module.css +4 -0
  197. package/src/theme/Tag/index.tsx +2 -4
  198. package/src/theme/TagsListInline/index.tsx +1 -1
  199. package/src/theme-classic.d.ts +315 -33
  200. package/src/validateThemeConfig.ts +80 -13
  201. package/lib/types.d.ts +0 -11
  202. package/lib-next/theme/DocPage/styles.module.css +0 -82
  203. package/src/theme/DocPage/styles.module.css +0 -82
  204. package/src/types.d.ts +0 -11
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import {isActiveSidebarItem, ThemeClassNames} from '@docusaurus/theme-common';
11
+ import Link from '@docusaurus/Link';
12
+ import isInternalUrl from '@docusaurus/isInternalUrl';
13
+ import IconExternalLink from '@theme/IconExternalLink';
14
+
15
+ import type {Props} from '@theme/DocSidebarItem/Link';
16
+
17
+ import styles from './Link.module.css';
18
+
19
+ export default function DocSidebarItemLink({
20
+ item,
21
+ onItemClick,
22
+ activePath,
23
+ level,
24
+ index,
25
+ ...props
26
+ }: Props): JSX.Element {
27
+ const {href, label, className} = item;
28
+ const isActive = isActiveSidebarItem(item, activePath);
29
+ const isInternalLink = isInternalUrl(href);
30
+ return (
31
+ <li
32
+ className={clsx(
33
+ ThemeClassNames.docs.docSidebarItemLink,
34
+ ThemeClassNames.docs.docSidebarItemLinkLevel(level),
35
+ 'menu__list-item',
36
+ className,
37
+ )}
38
+ key={label}>
39
+ <Link
40
+ className={clsx(
41
+ 'menu__link',
42
+ !isInternalLink && styles.menuExternalLink,
43
+ {
44
+ 'menu__link--active': isActive,
45
+ },
46
+ )}
47
+ aria-current={isActive ? 'page' : undefined}
48
+ to={href}
49
+ {...(isInternalLink && {
50
+ onClick: onItemClick ? () => onItemClick(item) : undefined,
51
+ })}
52
+ {...props}>
53
+ {label}
54
+ {!isInternalLink && <IconExternalLink />}
55
+ </Link>
56
+ </li>
57
+ );
58
+ }
@@ -5,34 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useEffect, useMemo} from 'react';
9
- import clsx from 'clsx';
10
- import {
11
- isActiveSidebarItem,
12
- usePrevious,
13
- Collapsible,
14
- useCollapsible,
15
- findFirstCategoryLink,
16
- ThemeClassNames,
17
- useThemeConfig,
18
- useDocSidebarItemsExpandedState,
19
- isSamePath,
20
- } from '@docusaurus/theme-common';
21
- import Link from '@docusaurus/Link';
22
- import isInternalUrl from '@docusaurus/isInternalUrl';
23
- import {translate} from '@docusaurus/Translate';
24
- import IconExternalLink from '@theme/IconExternalLink';
25
-
26
- import DocSidebarItems from '@theme/DocSidebarItems';
8
+ import React from 'react';
9
+ import DocSidebarItemCategory from '@theme/DocSidebarItem/Category';
10
+ import DocSidebarItemLink from '@theme/DocSidebarItem/Link';
11
+ import DocSidebarItemHtml from '@theme/DocSidebarItem/Html';
27
12
  import type {Props} from '@theme/DocSidebarItem';
28
- import type {
29
- PropSidebarItemCategory,
30
- PropSidebarItemLink,
31
- } from '@docusaurus/plugin-content-docs';
32
-
33
- import styles from './styles.module.css';
34
- import useIsBrowser from '@docusaurus/useIsBrowser';
35
- import type {SidebarItemHtml} from '@docusaurus/plugin-content-docs/src/sidebars/types';
36
13
 
37
14
  export default function DocSidebarItem({
38
15
  item,
@@ -48,235 +25,3 @@ export default function DocSidebarItem({
48
25
  return <DocSidebarItemLink item={item} {...props} />;
49
26
  }
50
27
  }
51
-
52
- // If we navigate to a category and it becomes active, it should automatically
53
- // expand itself
54
- function useAutoExpandActiveCategory({
55
- isActive,
56
- collapsed,
57
- setCollapsed,
58
- }: {
59
- isActive: boolean;
60
- collapsed: boolean;
61
- setCollapsed: (b: boolean) => void;
62
- }) {
63
- const wasActive = usePrevious(isActive);
64
- useEffect(() => {
65
- const justBecameActive = isActive && !wasActive;
66
- if (justBecameActive && collapsed) {
67
- setCollapsed(false);
68
- }
69
- }, [isActive, wasActive, collapsed, setCollapsed]);
70
- }
71
-
72
- /**
73
- * When a collapsible category has no link, we still link it to its first child
74
- * during SSR as a temporary fallback. This allows to be able to navigate inside
75
- * the category even when JS fails to load, is delayed or simply disabled
76
- * React hydration becomes an optional progressive enhancement
77
- * see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
78
- * see https://github.com/facebook/docusaurus/issues/3030
79
- */
80
- function useCategoryHrefWithSSRFallback(
81
- item: PropSidebarItemCategory,
82
- ): string | undefined {
83
- const isBrowser = useIsBrowser();
84
- return useMemo(() => {
85
- if (item.href) {
86
- return item.href;
87
- }
88
- // In these cases, it's not necessary to render a fallback
89
- // We skip the "findFirstCategoryLink" computation
90
- if (isBrowser || !item.collapsible) {
91
- return undefined;
92
- }
93
- return findFirstCategoryLink(item);
94
- }, [item, isBrowser]);
95
- }
96
-
97
- function DocSidebarItemCategory({
98
- item,
99
- onItemClick,
100
- activePath,
101
- level,
102
- index,
103
- ...props
104
- }: Props & {item: PropSidebarItemCategory}) {
105
- const {items, label, collapsible, className, href} = item;
106
- const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
107
-
108
- const isActive = isActiveSidebarItem(item, activePath);
109
- const isCurrentPage = isSamePath(href, activePath);
110
-
111
- const {collapsed, setCollapsed} = useCollapsible({
112
- // active categories are always initialized as expanded
113
- // the default (item.collapsed) is only used for non-active categories
114
- initialState: () => {
115
- if (!collapsible) {
116
- return false;
117
- }
118
- return isActive ? false : item.collapsed;
119
- },
120
- });
121
-
122
- useAutoExpandActiveCategory({isActive, collapsed, setCollapsed});
123
- const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
124
- function updateCollapsed(toCollapsed: boolean = !collapsed) {
125
- setExpandedItem(toCollapsed ? null : index);
126
- setCollapsed(toCollapsed);
127
- }
128
- const {autoCollapseSidebarCategories} = useThemeConfig();
129
- useEffect(() => {
130
- if (
131
- collapsible &&
132
- expandedItem &&
133
- expandedItem !== index &&
134
- autoCollapseSidebarCategories
135
- ) {
136
- setCollapsed(true);
137
- }
138
- }, [
139
- collapsible,
140
- expandedItem,
141
- index,
142
- setCollapsed,
143
- autoCollapseSidebarCategories,
144
- ]);
145
-
146
- return (
147
- <li
148
- className={clsx(
149
- ThemeClassNames.docs.docSidebarItemCategory,
150
- ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
151
- 'menu__list-item',
152
- {
153
- 'menu__list-item--collapsed': collapsed,
154
- },
155
- className,
156
- )}>
157
- <div
158
- className={clsx('menu__list-item-collapsible', {
159
- 'menu__list-item-collapsible--active': isCurrentPage,
160
- })}>
161
- <Link
162
- className={clsx('menu__link', {
163
- 'menu__link--sublist': collapsible,
164
- 'menu__link--sublist-caret': !href,
165
- 'menu__link--active': isActive,
166
- })}
167
- onClick={
168
- collapsible
169
- ? (e) => {
170
- onItemClick?.(item);
171
- if (href) {
172
- updateCollapsed(false);
173
- } else {
174
- e.preventDefault();
175
- updateCollapsed();
176
- }
177
- }
178
- : () => {
179
- onItemClick?.(item);
180
- }
181
- }
182
- aria-current={isCurrentPage ? 'page' : undefined}
183
- aria-expanded={collapsible ? !collapsed : undefined}
184
- href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
185
- {...props}>
186
- {label}
187
- </Link>
188
- {href && collapsible && (
189
- <button
190
- aria-label={translate(
191
- {
192
- id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
193
- message: "Toggle the collapsible sidebar category '{label}'",
194
- description:
195
- 'The ARIA label to toggle the collapsible sidebar category',
196
- },
197
- {label},
198
- )}
199
- type="button"
200
- className="clean-btn menu__caret"
201
- onClick={(e) => {
202
- e.preventDefault();
203
- updateCollapsed();
204
- }}
205
- />
206
- )}
207
- </div>
208
-
209
- <Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
210
- <DocSidebarItems
211
- items={items}
212
- tabIndex={collapsed ? -1 : 0}
213
- onItemClick={onItemClick}
214
- activePath={activePath}
215
- level={level + 1}
216
- />
217
- </Collapsible>
218
- </li>
219
- );
220
- }
221
-
222
- function DocSidebarItemHtml({
223
- item,
224
- level,
225
- index,
226
- }: Props & {item: SidebarItemHtml}) {
227
- const {value, defaultStyle, className} = item;
228
- return (
229
- <li
230
- className={clsx(
231
- ThemeClassNames.docs.docSidebarItemLink,
232
- ThemeClassNames.docs.docSidebarItemLinkLevel(level),
233
- defaultStyle && `${styles.menuHtmlItem} menu__list-item`,
234
- className,
235
- )}
236
- key={index}
237
- // eslint-disable-next-line react/no-danger
238
- dangerouslySetInnerHTML={{__html: value}}
239
- />
240
- );
241
- }
242
-
243
- function DocSidebarItemLink({
244
- item,
245
- onItemClick,
246
- activePath,
247
- level,
248
- index,
249
- ...props
250
- }: Props & {item: PropSidebarItemLink}) {
251
- const {href, label, className} = item;
252
- const isActive = isActiveSidebarItem(item, activePath);
253
- const isInternalLink = isInternalUrl(href);
254
- return (
255
- <li
256
- className={clsx(
257
- ThemeClassNames.docs.docSidebarItemLink,
258
- ThemeClassNames.docs.docSidebarItemLinkLevel(level),
259
- 'menu__list-item',
260
- className,
261
- )}
262
- key={label}>
263
- <Link
264
- className={clsx(
265
- 'menu__link',
266
- !isInternalLink && styles.menuExternalLink,
267
- {
268
- 'menu__link--active': isActive,
269
- },
270
- )}
271
- aria-current={isActive ? 'page' : undefined}
272
- to={href}
273
- {...(isInternalLink && {
274
- onClick: onItemClick ? () => onItemClick(item) : undefined,
275
- })}
276
- {...props}>
277
- {label}
278
- {!isInternalLink && <IconExternalLink />}
279
- </Link>
280
- </li>
281
- );
282
- }
@@ -17,12 +17,7 @@ function DocSidebarItems({items, ...props}: Props): JSX.Element {
17
17
  return (
18
18
  <DocSidebarItemsExpandedStateProvider>
19
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
- />
20
+ <DocSidebarItem key={index} item={item} index={index} {...props} />
26
21
  ))}
27
22
  </DocSidebarItemsExpandedStateProvider>
28
23
  );
@@ -15,7 +15,6 @@ import {
15
15
  ThemeClassNames,
16
16
  usePluralForm,
17
17
  } from '@docusaurus/theme-common';
18
- import type {PropTagDocListDoc} from '@docusaurus/plugin-content-docs';
19
18
  import Translate, {translate} from '@docusaurus/Translate';
20
19
  import type {Props} from '@theme/DocTagDocListPage';
21
20
  import SearchMetadata from '@theme/SearchMetadata';
@@ -39,7 +38,7 @@ function useNDocsTaggedPlural() {
39
38
  );
40
39
  }
41
40
 
42
- function DocItem({doc}: {doc: PropTagDocListDoc}): JSX.Element {
41
+ function DocItem({doc}: {doc: Props['tag']['items'][number]}): JSX.Element {
43
42
  return (
44
43
  <article className="margin-vert--lg">
45
44
  <Link to={doc.permalink}>
@@ -58,7 +57,7 @@ export default function DocTagDocListPage({tag}: Props): JSX.Element {
58
57
  description: 'The title of the page for a docs tag',
59
58
  message: '{nDocsTagged} with "{tagName}"',
60
59
  },
61
- {nDocsTagged: nDocsTaggedPlural(tag.docs.length), tagName: tag.name},
60
+ {nDocsTagged: nDocsTaggedPlural(tag.count), tagName: tag.label},
62
61
  );
63
62
 
64
63
  return (
@@ -84,7 +83,7 @@ export default function DocTagDocListPage({tag}: Props): JSX.Element {
84
83
  </Link>
85
84
  </header>
86
85
  <section className="margin-vert--lg">
87
- {tag.docs.map((doc) => (
86
+ {tag.items.map((doc) => (
88
87
  <DocItem key={doc.id} doc={doc} />
89
88
  ))}
90
89
  </section>
@@ -136,8 +136,8 @@ function DocVersionBannerEnabled({
136
136
  const {latestDocSuggestion, latestVersionSuggestion} =
137
137
  useDocVersionSuggestions(pluginId);
138
138
 
139
- // try to link to same doc in latest version (not always possible)
140
- // fallback to main doc of latest version
139
+ // Try to link to same doc in latest version (not always possible), falling
140
+ // back to main doc of latest version
141
141
  const latestVersionSuggestedDoc =
142
142
  latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
143
143
 
@@ -31,7 +31,7 @@ function Column({column}: {column: ColumnType}) {
31
31
  return (
32
32
  <div className="col footer__col">
33
33
  <div className="footer__title">{column.title}</div>
34
- <ul className="footer__items">
34
+ <ul className="footer__items clean-list">
35
35
  {column.items.map((item, i) => (
36
36
  <ColumnLinkItem key={i} item={item} />
37
37
  ))}
@@ -13,13 +13,13 @@ import {useThemeConfig} from '@docusaurus/theme-common';
13
13
 
14
14
  import styles from './styles.module.css';
15
15
 
16
- function AnchorHeading({as: As, id, ...props}: Props) {
16
+ export default function Heading({as: As, id, ...props}: Props): JSX.Element {
17
17
  const {
18
18
  navbar: {hideOnScroll},
19
19
  } = useThemeConfig();
20
-
21
- if (!id) {
22
- return <As {...props} />;
20
+ // H1 headings do not need an id because they don't appear in the TOC.
21
+ if (As === 'h1' || !id) {
22
+ return <As {...props} id={undefined} />;
23
23
  }
24
24
 
25
25
  return (
@@ -46,17 +46,3 @@ function AnchorHeading({as: As, id, ...props}: Props) {
46
46
  </As>
47
47
  );
48
48
  }
49
-
50
- export default function Heading({as, ...props}: Props): JSX.Element {
51
- if (as === 'h1') {
52
- return (
53
- <h1
54
- {...props}
55
- id={undefined} // h1 headings do not need an id because they don't appear in the TOC
56
- >
57
- {props.children}
58
- </h1>
59
- );
60
- }
61
- return <AnchorHeading as={as} {...props} />;
62
- }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import type {Props} from '@theme/IconHome';
10
+
11
+ export default function IconHome(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 24 24" {...props}>
14
+ <path
15
+ d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -82,6 +82,7 @@ export default function LastUpdated({
82
82
  </Translate>
83
83
  {process.env.NODE_ENV === 'development' && (
84
84
  <div>
85
+ {/* eslint-disable-next-line @docusaurus/no-untranslated-text */}
85
86
  <small> (Simulated during dev for better perf)</small>
86
87
  </div>
87
88
  )}
@@ -27,7 +27,7 @@ export default function Layout(props: Props): JSX.Element {
27
27
  children,
28
28
  noFooter,
29
29
  wrapperClassName,
30
- // not really layout-related, but kept for convenience/retro-compatibility
30
+ // Not really layout-related, but kept for convenience/retro-compatibility
31
31
  title,
32
32
  description,
33
33
  } = props;
@@ -13,9 +13,8 @@ export default function MDXDetails(props: Props): JSX.Element {
13
13
  const items = React.Children.toArray(props.children) as ReactElement[];
14
14
  // Split summary item from the rest to pass it as a separate prop to the
15
15
  // Details theme component
16
- const summary: ReactElement<ComponentProps<'summary'>> = items.find(
17
- (item) => item?.props?.mdxType === 'summary',
18
- )!;
16
+ const summary: ReactElement<ComponentProps<'summary'>> | undefined =
17
+ items.find((item) => item?.props?.mdxType === 'summary');
19
18
  const children = <>{items.filter((item) => item !== summary)}</>;
20
19
 
21
20
  return (
@@ -9,17 +9,13 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import type {Props} from '@theme/MDXComponents/Ul';
11
11
 
12
- import styles from './Ul.module.css';
13
-
14
- const containsClassListLocalClass = styles['contains-task-list'];
15
-
16
12
  function transformUlClassName(className?: string): string {
17
13
  return clsx(
18
14
  className,
19
15
  // This class is set globally by GitHub/MDX
20
- // We keep the global class, but apply scoped CSS
16
+ // We keep the global class, but add Infima class to get list without styling
21
17
  // See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
22
- className?.includes('contains-task-list') && containsClassListLocalClass,
18
+ className?.includes('contains-task-list') && 'clean-list',
23
19
  );
24
20
  }
25
21
 
@@ -17,6 +17,7 @@ import {
17
17
  } from '@docusaurus/theme-common';
18
18
  import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
19
19
  import NavbarLogo from '@theme/Navbar/Logo';
20
+ import NavbarSearch from '@theme/Navbar/Search';
20
21
  import styles from './styles.module.css';
21
22
 
22
23
  function useNavbarItems() {
@@ -73,7 +74,11 @@ export default function NavbarContent(): JSX.Element {
73
74
  <>
74
75
  <NavbarItems items={rightItems} />
75
76
  <NavbarColorModeToggle className={styles.colorModeToggle} />
76
- {autoAddSearchBar && <SearchBar />}
77
+ {autoAddSearchBar && (
78
+ <NavbarSearch>
79
+ <SearchBar />
80
+ </NavbarSearch>
81
+ )}
77
82
  </>
78
83
  }
79
84
  />
@@ -13,7 +13,7 @@ export default function NavbarLogo(): JSX.Element {
13
13
  <Logo
14
14
  className="navbar__brand"
15
15
  imageClassName="navbar__logo"
16
- titleClassName="navbar__title"
16
+ titleClassName="navbar__title text--truncate"
17
17
  />
18
18
  );
19
19
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import type {Props} from '@theme/Navbar/Search';
10
+
11
+ import styles from './styles.module.css';
12
+
13
+ export default function NavbarSearch({children}: Props): JSX.Element {
14
+ return <div className={styles.searchBox}>{children}</div>;
15
+ }
@@ -0,0 +1,20 @@
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
+ @media (max-width: 996px) {
9
+ .searchBox {
10
+ position: absolute;
11
+ right: var(--ifm-navbar-padding-horizontal);
12
+ }
13
+ }
14
+
15
+ @media (min-width: 997px) {
16
+ .searchBox {
17
+ padding: var(--ifm-navbar-item-padding-vertical)
18
+ var(--ifm-navbar-item-padding-horizontal);
19
+ }
20
+ }
@@ -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 DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
9
+ import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
10
+ import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
11
+ import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
12
+ import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
13
+ import DocNavbarItem from '@theme/NavbarItem/DocNavbarItem';
14
+ import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
15
+ import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
16
+ import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
17
+
18
+ import type {ComponentTypesObject} from '@theme/NavbarItem/ComponentTypes';
19
+
20
+ const ComponentTypes: ComponentTypesObject = {
21
+ default: DefaultNavbarItem,
22
+ localeDropdown: LocaleDropdownNavbarItem,
23
+ search: SearchNavbarItem,
24
+ dropdown: DropdownNavbarItem,
25
+ html: HtmlNavbarItem,
26
+ doc: DocNavbarItem,
27
+ docSidebar: DocSidebarNavbarItem,
28
+ docsVersion: DocsVersionNavbarItem,
29
+ docsVersionDropdown: DocsVersionDropdownNavbarItem,
30
+ };
31
+
32
+ export default ComponentTypes;