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

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 (143) hide show
  1. package/lib/getSwizzleConfig.js +102 -0
  2. package/lib/index.js +14 -11
  3. package/lib/theme-classic.d.ts +123 -97
  4. package/lib/translations.js +29 -32
  5. package/lib/validateThemeConfig.js +7 -4
  6. package/lib-next/theme/AnnouncementBar/index.js +1 -4
  7. package/lib-next/theme/BackToTopButton/index.js +6 -6
  8. package/lib-next/theme/BackToTopButton/styles.module.css +3 -1
  9. package/lib-next/theme/BlogLayout/index.js +1 -4
  10. package/lib-next/theme/BlogListPage/index.js +1 -4
  11. package/lib-next/theme/BlogListPaginator/index.js +1 -4
  12. package/lib-next/theme/BlogPostAuthor/index.js +18 -24
  13. package/lib-next/theme/BlogPostItem/index.js +12 -4
  14. package/lib-next/theme/BlogPostPage/index.js +4 -6
  15. package/lib-next/theme/BlogPostPaginator/index.js +1 -4
  16. package/lib-next/theme/BlogTagsListPage/index.js +1 -4
  17. package/lib-next/theme/BlogTagsPostsPage/index.js +4 -2
  18. package/lib-next/theme/CodeBlock/index.js +2 -1
  19. package/lib-next/theme/Details/index.js +2 -1
  20. package/lib-next/theme/DocBreadcrumbs/index.js +76 -0
  21. package/lib-next/theme/DocBreadcrumbs/styles.module.css +26 -0
  22. package/lib-next/theme/DocCard/index.js +12 -1
  23. package/lib-next/theme/DocCard/styles.module.css +1 -1
  24. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +2 -0
  25. package/lib-next/theme/DocItem/index.js +8 -5
  26. package/lib-next/theme/DocPage/index.js +2 -4
  27. package/lib-next/theme/DocPage/styles.module.css +3 -3
  28. package/lib-next/theme/DocPaginator/index.js +1 -4
  29. package/lib-next/theme/DocSidebar/styles.module.css +4 -4
  30. package/lib-next/theme/DocSidebarItem/index.js +39 -14
  31. package/lib-next/theme/DocSidebarItem/styles.module.css +3 -10
  32. package/lib-next/theme/DocTagsListPage/index.js +1 -4
  33. package/lib-next/theme/DocVersionBadge/index.js +8 -1
  34. package/lib-next/theme/Footer/index.js +8 -4
  35. package/lib-next/theme/Heading/index.js +0 -1
  36. package/lib-next/theme/Heading/styles.module.css +16 -0
  37. package/lib-next/theme/IconArrow/index.js +1 -4
  38. package/lib-next/theme/IconEdit/index.js +1 -4
  39. package/lib-next/theme/IconExternalLink/index.js +1 -4
  40. package/lib-next/theme/IconLanguage/index.js +1 -4
  41. package/lib-next/theme/IconMenu/index.js +6 -4
  42. package/lib-next/theme/Layout/index.js +1 -4
  43. package/lib-next/theme/LayoutHead/index.js +4 -0
  44. package/lib-next/theme/Logo/index.js +1 -4
  45. package/lib-next/theme/MDXComponents/index.js +4 -3
  46. package/lib-next/theme/MDXPage/index.js +1 -4
  47. package/lib-next/theme/Navbar/index.js +1 -3
  48. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +1 -3
  49. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -2
  50. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +1 -3
  51. package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +8 -1
  52. package/lib-next/theme/NavbarItem/index.js +2 -2
  53. package/lib-next/theme/NotFound.js +1 -4
  54. package/lib-next/theme/PaginatorNavLink/index.js +1 -4
  55. package/lib-next/theme/SearchBar.js +1 -1
  56. package/lib-next/theme/SearchMetadata/index.js +11 -6
  57. package/lib-next/theme/SkipToContent/index.js +1 -3
  58. package/lib-next/theme/TOC/index.js +2 -5
  59. package/lib-next/theme/TOCInline/index.js +1 -4
  60. package/lib-next/theme/TOCItems/index.js +3 -3
  61. package/lib-next/theme/TabItem/index.js +1 -4
  62. package/lib-next/theme/Tabs/__tests__/index.test.js +3 -1
  63. package/lib-next/theme/Tabs/index.js +1 -1
  64. package/lib-next/theme/Tag/index.js +1 -4
  65. package/lib-next/theme/TagsListByLetter/index.js +1 -3
  66. package/lib-next/theme/ThemedImage/index.js +1 -4
  67. package/lib-next/theme/ThemedImage/styles.module.css +2 -2
  68. package/lib-next/theme/Toggle/index.js +25 -2
  69. package/lib-next/theme/prism-include-languages.js +17 -23
  70. package/package.json +21 -22
  71. package/src/getSwizzleConfig.ts +101 -0
  72. package/src/index.ts +7 -21
  73. package/src/theme/AnnouncementBar/index.tsx +1 -3
  74. package/src/theme/BackToTopButton/index.tsx +8 -7
  75. package/src/theme/BackToTopButton/styles.module.css +3 -1
  76. package/src/theme/BlogLayout/index.tsx +1 -3
  77. package/src/theme/BlogListPage/index.tsx +1 -3
  78. package/src/theme/BlogListPaginator/index.tsx +1 -3
  79. package/src/theme/BlogPostAuthor/index.tsx +18 -23
  80. package/src/theme/BlogPostItem/index.tsx +10 -4
  81. package/src/theme/BlogPostPage/index.tsx +4 -5
  82. package/src/theme/BlogPostPaginator/index.tsx +1 -3
  83. package/src/theme/BlogTagsListPage/index.tsx +1 -3
  84. package/src/theme/BlogTagsPostsPage/index.tsx +3 -1
  85. package/src/theme/CodeBlock/index.tsx +2 -1
  86. package/src/theme/Details/index.tsx +2 -1
  87. package/src/theme/DocBreadcrumbs/index.tsx +91 -0
  88. package/src/theme/DocBreadcrumbs/styles.module.css +26 -0
  89. package/src/theme/DocCard/index.tsx +10 -1
  90. package/src/theme/DocCard/styles.module.css +1 -1
  91. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +2 -0
  92. package/src/theme/DocItem/index.tsx +7 -4
  93. package/src/theme/DocPage/index.tsx +2 -4
  94. package/src/theme/DocPage/styles.module.css +3 -3
  95. package/src/theme/DocPaginator/index.tsx +1 -3
  96. package/src/theme/DocSidebar/styles.module.css +4 -4
  97. package/src/theme/DocSidebarItem/index.tsx +43 -13
  98. package/src/theme/DocSidebarItem/styles.module.css +3 -10
  99. package/src/theme/DocTagsListPage/index.tsx +1 -3
  100. package/src/theme/DocVersionBadge/index.tsx +6 -1
  101. package/src/theme/Footer/index.tsx +8 -4
  102. package/src/theme/Heading/index.tsx +0 -1
  103. package/src/theme/Heading/styles.module.css +16 -0
  104. package/src/theme/IconArrow/index.tsx +1 -3
  105. package/src/theme/IconEdit/index.tsx +4 -3
  106. package/src/theme/IconExternalLink/index.tsx +4 -3
  107. package/src/theme/IconLanguage/index.tsx +5 -3
  108. package/src/theme/IconMenu/index.tsx +1 -3
  109. package/src/theme/Layout/index.tsx +1 -3
  110. package/src/theme/LayoutHead/index.tsx +4 -0
  111. package/src/theme/Logo/index.tsx +1 -3
  112. package/src/theme/MDXComponents/index.tsx +4 -3
  113. package/src/theme/MDXPage/index.tsx +1 -3
  114. package/src/theme/Navbar/index.tsx +1 -3
  115. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +1 -3
  116. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -2
  117. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -3
  118. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +8 -1
  119. package/src/theme/NavbarItem/index.tsx +2 -2
  120. package/src/theme/NotFound.tsx +1 -3
  121. package/src/theme/PaginatorNavLink/index.tsx +1 -3
  122. package/src/theme/SearchBar.tsx +2 -1
  123. package/src/theme/SearchMetadata/index.tsx +12 -6
  124. package/src/theme/SkipToContent/index.tsx +1 -3
  125. package/src/theme/TOC/index.tsx +3 -5
  126. package/src/theme/TOCCollapsible/index.tsx +2 -2
  127. package/src/theme/TOCInline/index.tsx +3 -5
  128. package/src/theme/TOCItems/index.tsx +11 -7
  129. package/src/theme/TabItem/index.tsx +5 -3
  130. package/src/theme/Tabs/index.tsx +1 -1
  131. package/src/theme/Tag/index.tsx +1 -3
  132. package/src/theme/TagsListByLetter/index.tsx +1 -3
  133. package/src/theme/ThemedImage/index.tsx +1 -3
  134. package/src/theme/ThemedImage/styles.module.css +2 -2
  135. package/src/theme/Toggle/index.tsx +26 -2
  136. package/src/theme/prism-include-languages.ts +20 -23
  137. package/src/theme-classic.d.ts +123 -97
  138. package/src/translations.ts +41 -39
  139. package/src/validateThemeConfig.ts +10 -8
  140. package/lib-next/theme/DocSidebarItems/styles.module.css +0 -20
  141. package/lib-next/theme/Heading/styles.css +0 -22
  142. package/src/theme/DocSidebarItems/styles.module.css +0 -20
  143. package/src/theme/Heading/styles.css +0 -22
@@ -16,18 +16,19 @@ import TOCCollapsible from '@theme/TOCCollapsible';
16
16
  import Heading from '@theme/Heading';
17
17
  import styles from './styles.module.css';
18
18
  import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
19
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
19
20
  export default function DocItem(props) {
20
21
  const {content: DocContent} = props;
21
- const {metadata, frontMatter} = DocContent;
22
+ const {metadata, frontMatter, assets} = DocContent;
22
23
  const {
23
- image,
24
24
  keywords,
25
25
  hide_title: hideTitle,
26
26
  hide_table_of_contents: hideTableOfContents,
27
27
  toc_min_heading_level: tocMinHeadingLevel,
28
28
  toc_max_heading_level: tocMaxHeadingLevel,
29
29
  } = frontMatter;
30
- const {description, title} = metadata; // We only add a title if:
30
+ const {description, title} = metadata;
31
+ const image = assets.image ?? frontMatter.image; // We only add a title if:
31
32
  // - user asks to hide it with front matter
32
33
  // - the markdown content does not already contain a top-level h1 heading
33
34
 
@@ -57,6 +58,7 @@ export default function DocItem(props) {
57
58
  <DocVersionBanner />
58
59
  <div className={styles.docItemContainer}>
59
60
  <article>
61
+ <DocBreadcrumbs />
60
62
  <DocVersionBadge />
61
63
 
62
64
  {canRenderTOC && (
@@ -74,8 +76,9 @@ export default function DocItem(props) {
74
76
  <div
75
77
  className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
76
78
  {/*
77
- Title can be declared inside md content or declared through front matter and added manually
78
- To make both cases consistent, the added title is added under the same div.markdown block
79
+ Title can be declared inside md content or declared through
80
+ front matter and added manually. To make both cases consistent,
81
+ the added title is added under the same div.markdown block
79
82
  See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
80
83
  */}
81
84
  {shouldAddTitle && (
@@ -131,7 +131,7 @@ function DocPageContent({
131
131
  );
132
132
  }
133
133
 
134
- function DocPage(props) {
134
+ export default function DocPage(props) {
135
135
  const {
136
136
  route: {routes: docRoutes},
137
137
  versionMetadata,
@@ -152,7 +152,7 @@ function DocPage(props) {
152
152
  return (
153
153
  <>
154
154
  <Head>
155
- {/* TODO we should add a core addRoute({htmlClassName}) generic plugin option */}
155
+ {/* TODO we should add a core addRoute({htmlClassName}) action */}
156
156
  <html className={versionMetadata.className} />
157
157
  </Head>
158
158
  <DocsVersionProvider version={versionMetadata}>
@@ -170,5 +170,3 @@ function DocPage(props) {
170
170
  </>
171
171
  );
172
172
  }
173
-
174
- export default DocPage;
@@ -69,12 +69,12 @@
69
69
  transform: rotate(0);
70
70
  }
71
71
 
72
- html[dir='rtl'] .expandSidebarButtonIcon {
72
+ [dir='rtl'] .expandSidebarButtonIcon {
73
73
  transform: rotate(180deg);
74
74
  }
75
75
 
76
- html[data-theme='dark'] .collapsedDocSidebar:hover,
77
- html[data-theme='dark'] .collapsedDocSidebar:focus {
76
+ [data-theme='dark'] .collapsedDocSidebar:hover,
77
+ [data-theme='dark'] .collapsedDocSidebar:focus {
78
78
  background-color: var(--collapse-button-bg-color-dark);
79
79
  }
80
80
 
@@ -7,8 +7,7 @@
7
7
  import React from 'react';
8
8
  import Translate, {translate} from '@docusaurus/Translate';
9
9
  import PaginatorNavLink from '@theme/PaginatorNavLink';
10
-
11
- function DocPaginator(props) {
10
+ export default function DocPaginator(props) {
12
11
  const {previous, next} = props;
13
12
  return (
14
13
  <nav
@@ -49,5 +48,3 @@ function DocPaginator(props) {
49
48
  </nav>
50
49
  );
51
50
  }
52
-
53
- export default DocPaginator;
@@ -72,16 +72,16 @@
72
72
  margin-top: 4px;
73
73
  }
74
74
 
75
- html[dir='rtl'] .collapseSidebarButtonIcon {
75
+ [dir='rtl'] .collapseSidebarButtonIcon {
76
76
  transform: rotate(0);
77
77
  }
78
78
 
79
- html[data-theme='dark'] .collapseSidebarButton {
79
+ [data-theme='dark'] .collapseSidebarButton {
80
80
  background-color: var(--collapse-button-bg-color-dark);
81
81
  }
82
82
 
83
- html[data-theme='dark'] .collapseSidebarButton:hover,
84
- html[data-theme='dark'] .collapseSidebarButton:focus {
83
+ [data-theme='dark'] .collapseSidebarButton:hover,
84
+ [data-theme='dark'] .collapseSidebarButton:focus {
85
85
  background-color: var(--ifm-color-emphasis-200);
86
86
  }
87
87
  }
@@ -15,6 +15,7 @@ import {
15
15
  ThemeClassNames,
16
16
  useThemeConfig,
17
17
  useDocSidebarItemsExpandedState,
18
+ isSamePath,
18
19
  } from '@docusaurus/theme-common';
19
20
  import Link from '@docusaurus/Link';
20
21
  import isInternalUrl from '@docusaurus/isInternalUrl';
@@ -26,17 +27,17 @@ import useIsBrowser from '@docusaurus/useIsBrowser';
26
27
  export default function DocSidebarItem({item, ...props}) {
27
28
  switch (item.type) {
28
29
  case 'category':
29
- if (item.items.length === 0) {
30
- return null;
31
- }
32
-
33
30
  return <DocSidebarItemCategory item={item} {...props} />;
34
31
 
32
+ case 'html':
33
+ return <DocSidebarItemHtml item={item} {...props} />;
34
+
35
35
  case 'link':
36
36
  default:
37
37
  return <DocSidebarItemLink item={item} {...props} />;
38
38
  }
39
- } // If we navigate to a category and it becomes active, it should automatically expand itself
39
+ } // If we navigate to a category and it becomes active, it should automatically
40
+ // expand itself
40
41
 
41
42
  function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
42
43
  const wasActive = usePrevious(isActive);
@@ -47,11 +48,15 @@ function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
47
48
  setCollapsed(false);
48
49
  }
49
50
  }, [isActive, wasActive, collapsed, setCollapsed]);
50
- } // When a collapsible category has no link, we still link it to its first child during SSR as a temporary fallback
51
- // This allows to be able to navigate inside the category even when JS fails to load, is delayed or simply disabled
52
- // React hydration becomes an optional progressive enhancement
53
- // see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
54
- // see https://github.com/facebook/docusaurus/issues/3030
51
+ }
52
+ /**
53
+ * When a collapsible category has no link, we still link it to its first child
54
+ * during SSR as a temporary fallback. This allows to be able to navigate inside
55
+ * the category even when JS fails to load, is delayed or simply disabled
56
+ * React hydration becomes an optional progressive enhancement
57
+ * see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
58
+ * see https://github.com/facebook/docusaurus/issues/3030
59
+ */
55
60
 
56
61
  function useCategoryHrefWithSSRFallback(item) {
57
62
  const isBrowser = useIsBrowser();
@@ -80,6 +85,7 @@ function DocSidebarItemCategory({
80
85
  const {items, label, collapsible, className, href} = item;
81
86
  const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
82
87
  const isActive = isActiveSidebarItem(item, activePath);
88
+ const isCurrentPage = isSamePath(href, activePath);
83
89
  const {collapsed, setCollapsed} = useCollapsible({
84
90
  // active categories are always initialized as expanded
85
91
  // the default (item.collapsed) is only used for non-active categories
@@ -131,13 +137,14 @@ function DocSidebarItemCategory({
131
137
  },
132
138
  className,
133
139
  )}>
134
- <div className="menu__list-item-collapsible">
140
+ <div
141
+ className={clsx('menu__list-item-collapsible', {
142
+ 'menu__list-item-collapsible--active': isCurrentPage,
143
+ })}>
135
144
  <Link
136
145
  className={clsx('menu__link', {
137
146
  'menu__link--sublist': collapsible && !href,
138
147
  'menu__link--active': isActive,
139
- [styles.menuLinkText]: !collapsible,
140
- [styles.hasHref]: !!hrefWithSSRFallback,
141
148
  })}
142
149
  onClick={
143
150
  collapsible
@@ -155,7 +162,7 @@ function DocSidebarItemCategory({
155
162
  onItemClick?.(item);
156
163
  }
157
164
  }
158
- aria-current={isActive ? 'page' : undefined}
165
+ aria-current={isCurrentPage ? 'page' : undefined}
159
166
  href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
160
167
  {...props}>
161
168
  {label}
@@ -196,6 +203,24 @@ function DocSidebarItemCategory({
196
203
  );
197
204
  }
198
205
 
206
+ function DocSidebarItemHtml({item, level, index}) {
207
+ const {value, defaultStyle, className} = item;
208
+ return (
209
+ <li
210
+ className={clsx(
211
+ ThemeClassNames.docs.docSidebarItemLink,
212
+ ThemeClassNames.docs.docSidebarItemLinkLevel(level),
213
+ defaultStyle && `${styles.menuHtmlItem} menu__list-item`,
214
+ className,
215
+ )}
216
+ key={index} // eslint-disable-next-line react/no-danger
217
+ dangerouslySetInnerHTML={{
218
+ __html: value,
219
+ }}
220
+ />
221
+ );
222
+ }
223
+
199
224
  function DocSidebarItemLink({
200
225
  item,
201
226
  onItemClick,
@@ -6,15 +6,8 @@
6
6
  */
7
7
 
8
8
  @media (min-width: 997px) {
9
- .menuLinkText {
10
- cursor: initial;
11
- }
12
-
13
- .menuLinkText:hover {
14
- background: none;
15
- }
16
-
17
- .menuLinkText.hasHref {
18
- cursor: pointer;
9
+ .menuHtmlItem {
10
+ padding: var(--ifm-menu-link-padding-vertical)
11
+ var(--ifm-menu-link-padding-horizontal);
19
12
  }
20
13
  }
@@ -11,8 +11,7 @@ import {
11
11
  translateTagsPageTitle,
12
12
  } from '@docusaurus/theme-common';
13
13
  import TagsListByLetter from '@theme/TagsListByLetter';
14
-
15
- function DocTagsListPage({tags}) {
14
+ export default function DocTagsListPage({tags}) {
16
15
  const title = translateTagsPageTitle();
17
16
  return (
18
17
  <Layout
@@ -34,5 +33,3 @@ function DocTagsListPage({tags}) {
34
33
  </Layout>
35
34
  );
36
35
  }
37
-
38
- export default DocTagsListPage;
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
+ import Translate from '@docusaurus/Translate';
8
9
  import {ThemeClassNames, useDocsVersion} from '@docusaurus/theme-common';
9
10
  import clsx from 'clsx';
10
11
  export default function DocVersionBadge({className}) {
@@ -18,7 +19,13 @@ export default function DocVersionBadge({className}) {
18
19
  ThemeClassNames.docs.docVersionBadge,
19
20
  'badge badge--secondary',
20
21
  )}>
21
- Version: {versionMetadata.label}
22
+ <Translate
23
+ id="theme.docs.versionBadge.label"
24
+ values={{
25
+ versionLabel: versionMetadata.label,
26
+ }}>
27
+ {'Version: {versionLabel}'}
28
+ </Translate>
22
29
  </span>
23
30
  );
24
31
  }
@@ -88,10 +88,9 @@ function SimpleLinks({links}) {
88
88
  return (
89
89
  <div className="footer__links">
90
90
  {links.map((item, key) => (
91
- <>
91
+ <React.Fragment key={key}>
92
92
  {item.html ? (
93
93
  <span
94
- key={key}
95
94
  className="footer__link-item" // Developer provided the HTML, so assume it's safe.
96
95
  // eslint-disable-next-line react/no-danger
97
96
  dangerouslySetInnerHTML={{
@@ -104,7 +103,7 @@ function SimpleLinks({links}) {
104
103
  {links.length !== key + 1 && (
105
104
  <span className="footer__link-separator">·</span>
106
105
  )}
107
- </>
106
+ </React.Fragment>
108
107
  ))}
109
108
  </div>
110
109
  );
@@ -157,7 +156,12 @@ function Footer() {
157
156
  />
158
157
  </Link>
159
158
  ) : (
160
- <FooterLogo alt={logo.alt} sources={sources} />
159
+ <FooterLogo
160
+ alt={logo.alt}
161
+ sources={sources}
162
+ width={logo.width}
163
+ height={logo.height}
164
+ />
161
165
  )}
162
166
  </div>
163
167
  )}
@@ -8,7 +8,6 @@ import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {translate} from '@docusaurus/Translate';
10
10
  import {useThemeConfig} from '@docusaurus/theme-common';
11
- import './styles.css';
12
11
  import styles from './styles.module.css';
13
12
 
14
13
  function AnchorHeading({as: As, id, ...props}) {
@@ -17,3 +17,19 @@ See https://twitter.com/JoshWComeau/status/1332015868725891076
17
17
  .anchorWithHideOnScrollNavbar {
18
18
  scroll-margin-top: 0.5rem;
19
19
  }
20
+
21
+ :global(.hash-link) {
22
+ opacity: 0;
23
+ padding-left: 0.5rem;
24
+ transition: opacity var(--ifm-transition-fast);
25
+ user-select: none;
26
+ }
27
+
28
+ :global(.hash-link::before) {
29
+ content: '#';
30
+ }
31
+
32
+ :global(.hash-link:focus),
33
+ :global(*:hover > .hash-link) {
34
+ opacity: 1;
35
+ }
@@ -5,8 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
-
9
- function IconArrow(props) {
8
+ export default function IconArrow(props) {
10
9
  return (
11
10
  <svg width="20" height="20" aria-hidden="true" {...props}>
12
11
  <g fill="#7a7a7a">
@@ -16,5 +15,3 @@ function IconArrow(props) {
16
15
  </svg>
17
16
  );
18
17
  }
19
-
20
- export default IconArrow;
@@ -7,8 +7,7 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import styles from './styles.module.css';
10
-
11
- function IconEdit({className, ...restProps}) {
10
+ export default function IconEdit({className, ...restProps}) {
12
11
  return (
13
12
  <svg
14
13
  fill="currentColor"
@@ -24,5 +23,3 @@ function IconEdit({className, ...restProps}) {
24
23
  </svg>
25
24
  );
26
25
  }
27
-
28
- export default IconEdit;
@@ -6,8 +6,7 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import styles from './styles.module.css';
9
-
10
- function IconExternalLink({width = 13.5, height = 13.5}) {
9
+ export default function IconExternalLink({width = 13.5, height = 13.5}) {
11
10
  return (
12
11
  <svg
13
12
  width={width}
@@ -22,5 +21,3 @@ function IconExternalLink({width = 13.5, height = 13.5}) {
22
21
  </svg>
23
22
  );
24
23
  }
25
-
26
- export default IconExternalLink;
@@ -5,8 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
-
9
- function IconLanguage({width = 20, height = 20, ...props}) {
8
+ export default function IconLanguage({width = 20, height = 20, ...props}) {
10
9
  return (
11
10
  <svg
12
11
  viewBox="0 0 20 20"
@@ -21,5 +20,3 @@ function IconLanguage({width = 20, height = 20, ...props}) {
21
20
  </svg>
22
21
  );
23
22
  }
24
-
25
- export default IconLanguage;
@@ -5,8 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
-
9
- function IconMenu({width = 30, height = 30, className, ...restProps}) {
8
+ export default function IconMenu({
9
+ width = 30,
10
+ height = 30,
11
+ className,
12
+ ...restProps
13
+ }) {
10
14
  return (
11
15
  <svg
12
16
  className={className}
@@ -25,5 +29,3 @@ function IconMenu({width = 30, height = 30, className, ...restProps}) {
25
29
  </svg>
26
30
  );
27
31
  }
28
-
29
- export default IconMenu;
@@ -16,8 +16,7 @@ import LayoutHead from '@theme/LayoutHead';
16
16
  import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
17
17
  import ErrorPageContent from '@theme/ErrorPageContent';
18
18
  import './styles.css';
19
-
20
- function Layout(props) {
19
+ export default function Layout(props) {
21
20
  const {children, noFooter, wrapperClassName, pageClassName} = props;
22
21
  useKeyboardNavigation();
23
22
  return (
@@ -43,5 +42,3 @@ function Layout(props) {
43
42
  </LayoutProviders>
44
43
  );
45
44
  }
46
-
47
- export default Layout;
@@ -15,6 +15,7 @@ import {
15
15
  useTitleFormatter,
16
16
  useAlternatePageUtils,
17
17
  useThemeConfig,
18
+ keyboardFocusedClassName,
18
19
  } from '@docusaurus/theme-common';
19
20
  import {useLocation} from '@docusaurus/router'; // Useful for SEO
20
21
  // See https://developers.google.com/search/docs/advanced/crawling/localized-versions
@@ -94,6 +95,9 @@ export default function LayoutHead(props) {
94
95
  <title>{pageTitle}</title>
95
96
  <meta property="og:title" content={pageTitle} />
96
97
  <meta name="twitter:card" content="summary_large_image" />
98
+ {/* The keyboard focus class name need to be applied when SSR so links
99
+ are outlined when JS is disabled */}
100
+ <body className={keyboardFocusedClassName} />
97
101
  </Head>
98
102
 
99
103
  {/* image can override the default image */}
@@ -10,8 +10,7 @@ import ThemedImage from '@theme/ThemedImage';
10
10
  import useBaseUrl from '@docusaurus/useBaseUrl';
11
11
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
12
12
  import {useThemeConfig} from '@docusaurus/theme-common';
13
-
14
- function Logo(props) {
13
+ export default function Logo(props) {
15
14
  const {
16
15
  siteConfig: {title},
17
16
  } = useDocusaurusContext();
@@ -54,5 +53,3 @@ function Logo(props) {
54
53
  </Link>
55
54
  );
56
55
  }
57
-
58
- export default Logo;
@@ -10,8 +10,8 @@ import Link from '@docusaurus/Link';
10
10
  import CodeBlock from '@theme/CodeBlock';
11
11
  import Heading from '@theme/Heading';
12
12
  import Details from '@theme/Details';
13
- import './styles.css'; // MDX elements are wrapped through the MDX pragma
14
- // In some cases (notably usage with Head/Helmet) we need to unwrap those elements.
13
+ import './styles.css'; // MDX elements are wrapped through the MDX pragma. In some cases (notably usage
14
+ // with Head/Helmet) we need to unwrap those elements.
15
15
 
16
16
  function unwrapMDXElement(element) {
17
17
  if (element?.props?.mdxType && element?.props?.originalType) {
@@ -45,7 +45,8 @@ const MDXComponents = {
45
45
  />
46
46
  ),
47
47
  details: (props) => {
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
48
+ const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the
49
+ // Details theme component
49
50
 
50
51
  const summary = items.find((item) => item?.props?.mdxType === 'summary');
51
52
  const children = <>{items.filter((item) => item !== summary)}</>;
@@ -12,8 +12,7 @@ import MDXComponents from '@theme/MDXComponents';
12
12
  import TOC from '@theme/TOC';
13
13
  import {ThemeClassNames} from '@docusaurus/theme-common';
14
14
  import styles from './styles.module.css';
15
-
16
- function MDXPage(props) {
15
+ export default function MDXPage(props) {
17
16
  const {content: MDXPageContent} = props;
18
17
  const {
19
18
  metadata: {title, description, permalink, frontMatter},
@@ -48,5 +47,3 @@ function MDXPage(props) {
48
47
  </Layout>
49
48
  );
50
49
  }
51
-
52
- export default MDXPage;
@@ -206,7 +206,7 @@ function NavbarMobileSidebar({sidebarShown, toggleSidebar}) {
206
206
  );
207
207
  }
208
208
 
209
- function Navbar() {
209
+ export default function Navbar() {
210
210
  const {
211
211
  navbar: {hideOnScroll, style},
212
212
  } = useThemeConfig();
@@ -279,5 +279,3 @@ function Navbar() {
279
279
  </nav>
280
280
  );
281
281
  }
282
-
283
- export default Navbar;
@@ -43,7 +43,7 @@ function DefaultNavbarItemMobile({
43
43
  );
44
44
  }
45
45
 
46
- function DefaultNavbarItem({
46
+ export default function DefaultNavbarItem({
47
47
  mobile = false,
48
48
  position: _position,
49
49
  // Need to destructure position from props so that it doesn't get passed on.
@@ -59,5 +59,3 @@ function DefaultNavbarItem({
59
59
  />
60
60
  );
61
61
  }
62
-
63
- export default DefaultNavbarItem;
@@ -68,8 +68,8 @@ export default function DocsVersionDropdownNavbarItem({
68
68
  const dropdownTo =
69
69
  mobile && items.length > 1
70
70
  ? undefined
71
- : getVersionMainDoc(dropdownVersion).path; // We don't want to render a version dropdown with 0 or 1 item
72
- // If we build the site with a single docs version (onlyIncludeVersions: ['1.0.0'])
71
+ : getVersionMainDoc(dropdownVersion).path; // We don't want to render a version dropdown with 0 or 1 item. If we build
72
+ // the site with a single docs version (onlyIncludeVersions: ['1.0.0']),
73
73
  // We'd rather render a button instead of a dropdown
74
74
 
75
75
  if (items.length <= 1) {
@@ -150,9 +150,7 @@ function DropdownNavbarItemMobile({
150
150
  );
151
151
  }
152
152
 
153
- function DropdownNavbarItem({mobile = false, ...props}) {
153
+ export default function DropdownNavbarItem({mobile = false, ...props}) {
154
154
  const Comp = mobile ? DropdownNavbarItemMobile : DropdownNavbarItemDesktop;
155
155
  return <Comp {...props} />;
156
156
  }
157
-
158
- export default DropdownNavbarItem;
@@ -9,6 +9,7 @@ import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
9
9
  import IconLanguage from '@theme/IconLanguage';
10
10
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11
11
  import {useAlternatePageUtils} from '@docusaurus/theme-common';
12
+ import {translate} from '@docusaurus/Translate';
12
13
  import styles from './styles.module.css';
13
14
  export default function LocaleDropdownNavbarItem({
14
15
  mobile,
@@ -41,7 +42,13 @@ export default function LocaleDropdownNavbarItem({
41
42
  });
42
43
  const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter]; // Mobile is handled a bit differently
43
44
 
44
- const dropdownLabel = mobile ? 'Languages' : getLocaleLabel(currentLocale);
45
+ const dropdownLabel = mobile
46
+ ? translate({
47
+ message: 'Languages',
48
+ id: 'theme.navbar.mobileLanguageDropdown.label',
49
+ description: 'The label for the mobile language switcher dropdown',
50
+ })
51
+ : getLocaleLabel(currentLocale);
45
52
  return (
46
53
  <DropdownNavbarItem
47
54
  {...props}
@@ -14,8 +14,8 @@ const NavbarItemComponents = {
14
14
  localeDropdown: () => LocaleDropdownNavbarItem,
15
15
  search: () => SearchNavbarItem,
16
16
  dropdown: () => DropdownNavbarItem,
17
- // Need to lazy load these items as we don't know for sure the docs plugin is loaded
18
- // See https://github.com/facebook/docusaurus/issues/3360
17
+ // Need to lazy load these items as we don't know for sure the docs plugin is
18
+ // loaded. See https://github.com/facebook/docusaurus/issues/3360
19
19
 
20
20
  /* eslint-disable @typescript-eslint/no-var-requires, global-require */
21
21
  docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default,
@@ -7,8 +7,7 @@
7
7
  import React from 'react';
8
8
  import Layout from '@theme/Layout';
9
9
  import Translate, {translate} from '@docusaurus/Translate';
10
-
11
- function NotFound() {
10
+ export default function NotFound() {
12
11
  return (
13
12
  <Layout
14
13
  title={translate({
@@ -46,5 +45,3 @@ function NotFound() {
46
45
  </Layout>
47
46
  );
48
47
  }
49
-
50
- export default NotFound;
@@ -6,8 +6,7 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import Link from '@docusaurus/Link';
9
-
10
- function PaginatorNavLink(props) {
9
+ export default function PaginatorNavLink(props) {
11
10
  const {permalink, title, subLabel} = props;
12
11
  return (
13
12
  <Link className="pagination-nav__link" to={permalink}>
@@ -16,5 +15,3 @@ function PaginatorNavLink(props) {
16
15
  </Link>
17
16
  );
18
17
  }
19
-
20
- export default PaginatorNavLink;