@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
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import Translate from '@docusaurus/Translate';
9
10
  import {ThemeClassNames, useDocsVersion} from '@docusaurus/theme-common';
10
11
  import clsx from 'clsx';
11
12
  import type {Props} from '@theme/DocVersionBadge';
@@ -22,7 +23,11 @@ export default function DocVersionBadge({
22
23
  ThemeClassNames.docs.docVersionBadge,
23
24
  'badge badge--secondary',
24
25
  )}>
25
- Version: {versionMetadata.label}
26
+ <Translate
27
+ id="theme.docs.versionBadge.label"
28
+ values={{versionLabel: versionMetadata.label}}>
29
+ {'Version: {versionLabel}'}
30
+ </Translate>
26
31
  </span>
27
32
  );
28
33
  }
@@ -106,10 +106,9 @@ function SimpleLinks({links}: {links: SimpleFooter['links']}) {
106
106
  return (
107
107
  <div className="footer__links">
108
108
  {links.map((item, key) => (
109
- <>
109
+ <React.Fragment key={key}>
110
110
  {item.html ? (
111
111
  <span
112
- key={key}
113
112
  className="footer__link-item"
114
113
  // Developer provided the HTML, so assume it's safe.
115
114
  // eslint-disable-next-line react/no-danger
@@ -123,7 +122,7 @@ function SimpleLinks({links}: {links: SimpleFooter['links']}) {
123
122
  {links.length !== key + 1 && (
124
123
  <span className="footer__link-separator">·</span>
125
124
  )}
126
- </>
125
+ </React.Fragment>
127
126
  ))}
128
127
  </div>
129
128
  );
@@ -179,7 +178,12 @@ function Footer(): JSX.Element | null {
179
178
  />
180
179
  </Link>
181
180
  ) : (
182
- <FooterLogo alt={logo.alt} sources={sources} />
181
+ <FooterLogo
182
+ alt={logo.alt}
183
+ sources={sources}
184
+ width={logo.width}
185
+ height={logo.height}
186
+ />
183
187
  )}
184
188
  </div>
185
189
  )}
@@ -11,7 +11,6 @@ import type {Props} from '@theme/Heading';
11
11
  import {translate} from '@docusaurus/Translate';
12
12
  import {useThemeConfig} from '@docusaurus/theme-common';
13
13
 
14
- import './styles.css';
15
14
  import styles from './styles.module.css';
16
15
 
17
16
  function AnchorHeading({as: As, id, ...props}: 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
+ }
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import type {Props} from '@theme/IconArrow';
10
10
 
11
- function IconArrow(props: Props): JSX.Element {
11
+ export default function IconArrow(props: Props): JSX.Element {
12
12
  return (
13
13
  <svg width="20" height="20" aria-hidden="true" {...props}>
14
14
  <g fill="#7a7a7a">
@@ -18,5 +18,3 @@ function IconArrow(props: Props): JSX.Element {
18
18
  </svg>
19
19
  );
20
20
  }
21
-
22
- export default IconArrow;
@@ -12,7 +12,10 @@ import type {Props} from '@theme/IconEdit';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- function IconEdit({className, ...restProps}: Props): JSX.Element {
15
+ export default function IconEdit({
16
+ className,
17
+ ...restProps
18
+ }: Props): JSX.Element {
16
19
  return (
17
20
  <svg
18
21
  fill="currentColor"
@@ -28,5 +31,3 @@ function IconEdit({className, ...restProps}: Props): JSX.Element {
28
31
  </svg>
29
32
  );
30
33
  }
31
-
32
- export default IconEdit;
@@ -10,7 +10,10 @@ import type {Props} from '@theme/IconExternalLink';
10
10
 
11
11
  import styles from './styles.module.css';
12
12
 
13
- function IconExternalLink({width = 13.5, height = 13.5}: Props): JSX.Element {
13
+ export default function IconExternalLink({
14
+ width = 13.5,
15
+ height = 13.5,
16
+ }: Props): JSX.Element {
14
17
  return (
15
18
  <svg
16
19
  width={width}
@@ -25,5 +28,3 @@ function IconExternalLink({width = 13.5, height = 13.5}: Props): JSX.Element {
25
28
  </svg>
26
29
  );
27
30
  }
28
-
29
- export default IconExternalLink;
@@ -8,7 +8,11 @@
8
8
  import React from 'react';
9
9
  import type {Props} from '@theme/IconLanguage';
10
10
 
11
- function IconLanguage({width = 20, height = 20, ...props}: Props): JSX.Element {
11
+ export default function IconLanguage({
12
+ width = 20,
13
+ height = 20,
14
+ ...props
15
+ }: Props): JSX.Element {
12
16
  return (
13
17
  <svg
14
18
  viewBox="0 0 20 20"
@@ -23,5 +27,3 @@ function IconLanguage({width = 20, height = 20, ...props}: Props): JSX.Element {
23
27
  </svg>
24
28
  );
25
29
  }
26
-
27
- export default IconLanguage;
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import type {Props} from '@theme/IconMenu';
10
10
 
11
- function IconMenu({
11
+ export default function IconMenu({
12
12
  width = 30,
13
13
  height = 30,
14
14
  className,
@@ -32,5 +32,3 @@ function IconMenu({
32
32
  </svg>
33
33
  );
34
34
  }
35
-
36
- export default IconMenu;
@@ -19,7 +19,7 @@ import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
19
19
  import ErrorPageContent from '@theme/ErrorPageContent';
20
20
  import './styles.css';
21
21
 
22
- function Layout(props: Props): JSX.Element {
22
+ export default function Layout(props: Props): JSX.Element {
23
23
  const {children, noFooter, wrapperClassName, pageClassName} = props;
24
24
 
25
25
  useKeyboardNavigation();
@@ -47,5 +47,3 @@ function Layout(props: Props): JSX.Element {
47
47
  </LayoutProviders>
48
48
  );
49
49
  }
50
-
51
- export default Layout;
@@ -17,6 +17,7 @@ import {
17
17
  useTitleFormatter,
18
18
  useAlternatePageUtils,
19
19
  useThemeConfig,
20
+ keyboardFocusedClassName,
20
21
  } from '@docusaurus/theme-common';
21
22
  import {useLocation} from '@docusaurus/router';
22
23
 
@@ -101,6 +102,9 @@ export default function LayoutHead(props: Props): JSX.Element {
101
102
  <title>{pageTitle}</title>
102
103
  <meta property="og:title" content={pageTitle} />
103
104
  <meta name="twitter:card" content="summary_large_image" />
105
+ {/* The keyboard focus class name need to be applied when SSR so links
106
+ are outlined when JS is disabled */}
107
+ <body className={keyboardFocusedClassName} />
104
108
  </Head>
105
109
 
106
110
  {/* image can override the default image */}
@@ -14,7 +14,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
14
14
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
15
15
  import {useThemeConfig} from '@docusaurus/theme-common';
16
16
 
17
- function Logo(props: Props): JSX.Element {
17
+ export default function Logo(props: Props): JSX.Element {
18
18
  const {
19
19
  siteConfig: {title},
20
20
  } = useDocusaurusContext();
@@ -52,5 +52,3 @@ function Logo(props: Props): JSX.Element {
52
52
  </Link>
53
53
  );
54
54
  }
55
-
56
- export default Logo;
@@ -19,8 +19,8 @@ import type {MDXComponentsObject} from '@theme/MDXComponents';
19
19
 
20
20
  import './styles.css';
21
21
 
22
- // MDX elements are wrapped through the MDX pragma
23
- // In some cases (notably usage with Head/Helmet) we need to unwrap those elements.
22
+ // MDX elements are wrapped through the MDX pragma. In some cases (notably usage
23
+ // with Head/Helmet) we need to unwrap those elements.
24
24
  function unwrapMDXElement(element: ReactElement) {
25
25
  if (element?.props?.mdxType && element?.props?.originalType) {
26
26
  const {mdxType, originalType, ...newProps} = element.props;
@@ -55,7 +55,8 @@ const MDXComponents: MDXComponentsObject = {
55
55
  ),
56
56
  details: (props): JSX.Element => {
57
57
  const items = React.Children.toArray(props.children) as ReactElement[];
58
- // Split summary item from the rest to pass it as a separate prop to the Details theme component
58
+ // Split summary item from the rest to pass it as a separate prop to the
59
+ // Details theme component
59
60
  const summary: ReactElement<ComponentProps<'summary'>> = items.find(
60
61
  (item) => item?.props?.mdxType === 'summary',
61
62
  )!;
@@ -16,7 +16,7 @@ import {ThemeClassNames} from '@docusaurus/theme-common';
16
16
 
17
17
  import styles from './styles.module.css';
18
18
 
19
- function MDXPage(props: Props): JSX.Element {
19
+ export default function MDXPage(props: Props): JSX.Element {
20
20
  const {content: MDXPageContent} = props;
21
21
  const {
22
22
  metadata: {title, description, permalink, frontMatter},
@@ -52,5 +52,3 @@ function MDXPage(props: Props): JSX.Element {
52
52
  </Layout>
53
53
  );
54
54
  }
55
-
56
- export default MDXPage;
@@ -220,7 +220,7 @@ function NavbarMobileSidebar({
220
220
  );
221
221
  }
222
222
 
223
- function Navbar(): JSX.Element {
223
+ export default function Navbar(): JSX.Element {
224
224
  const {
225
225
  navbar: {hideOnScroll, style},
226
226
  } = useThemeConfig();
@@ -296,5 +296,3 @@ function Navbar(): JSX.Element {
296
296
  </nav>
297
297
  );
298
298
  }
299
-
300
- export default Navbar;
@@ -51,7 +51,7 @@ function DefaultNavbarItemMobile({
51
51
  );
52
52
  }
53
53
 
54
- function DefaultNavbarItem({
54
+ export default function DefaultNavbarItem({
55
55
  mobile = false,
56
56
  position: _position, // Need to destructure position from props so that it doesn't get passed on.
57
57
  ...props
@@ -66,5 +66,3 @@ function DefaultNavbarItem({
66
66
  />
67
67
  );
68
68
  }
69
-
70
- export default DefaultNavbarItem;
@@ -78,8 +78,8 @@ export default function DocsVersionDropdownNavbarItem({
78
78
  ? undefined
79
79
  : getVersionMainDoc(dropdownVersion).path;
80
80
 
81
- // We don't want to render a version dropdown with 0 or 1 item
82
- // If we build the site with a single docs version (onlyIncludeVersions: ['1.0.0'])
81
+ // We don't want to render a version dropdown with 0 or 1 item. If we build
82
+ // the site with a single docs version (onlyIncludeVersions: ['1.0.0']),
83
83
  // We'd rather render a button instead of a dropdown
84
84
  if (items.length <= 1) {
85
85
  return (
@@ -172,9 +172,10 @@ function DropdownNavbarItemMobile({
172
172
  );
173
173
  }
174
174
 
175
- function DropdownNavbarItem({mobile = false, ...props}: Props): JSX.Element {
175
+ export default function DropdownNavbarItem({
176
+ mobile = false,
177
+ ...props
178
+ }: Props): JSX.Element {
176
179
  const Comp = mobile ? DropdownNavbarItemMobile : DropdownNavbarItemDesktop;
177
180
  return <Comp {...props} />;
178
181
  }
179
-
180
- export default DropdownNavbarItem;
@@ -11,6 +11,7 @@ import IconLanguage from '@theme/IconLanguage';
11
11
  import type {Props} from '@theme/NavbarItem/LocaleDropdownNavbarItem';
12
12
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
13
13
  import {useAlternatePageUtils} from '@docusaurus/theme-common';
14
+ import {translate} from '@docusaurus/Translate';
14
15
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
15
16
 
16
17
  import styles from './styles.module.css';
@@ -48,7 +49,13 @@ export default function LocaleDropdownNavbarItem({
48
49
  const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter];
49
50
 
50
51
  // Mobile is handled a bit differently
51
- const dropdownLabel = mobile ? 'Languages' : getLocaleLabel(currentLocale);
52
+ const dropdownLabel = mobile
53
+ ? translate({
54
+ message: 'Languages',
55
+ id: 'theme.navbar.mobileLanguageDropdown.label',
56
+ description: 'The label for the mobile language switcher dropdown',
57
+ })
58
+ : getLocaleLabel(currentLocale);
52
59
 
53
60
  return (
54
61
  <DropdownNavbarItem
@@ -25,8 +25,8 @@ const NavbarItemComponents: Record<
25
25
  search: () => SearchNavbarItem,
26
26
  dropdown: () => DropdownNavbarItem,
27
27
 
28
- // Need to lazy load these items as we don't know for sure the docs plugin is loaded
29
- // See https://github.com/facebook/docusaurus/issues/3360
28
+ // Need to lazy load these items as we don't know for sure the docs plugin is
29
+ // loaded. See https://github.com/facebook/docusaurus/issues/3360
30
30
  /* eslint-disable @typescript-eslint/no-var-requires, global-require */
31
31
  docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default,
32
32
  docsVersionDropdown: () =>
@@ -9,7 +9,7 @@ import React from 'react';
9
9
  import Layout from '@theme/Layout';
10
10
  import Translate, {translate} from '@docusaurus/Translate';
11
11
 
12
- function NotFound(): JSX.Element {
12
+ export default function NotFound(): JSX.Element {
13
13
  return (
14
14
  <Layout
15
15
  title={translate({
@@ -47,5 +47,3 @@ function NotFound(): JSX.Element {
47
47
  </Layout>
48
48
  );
49
49
  }
50
-
51
- export default NotFound;
@@ -9,7 +9,7 @@ import React from 'react';
9
9
  import Link from '@docusaurus/Link';
10
10
  import type {Props} from '@theme/PaginatorNavLink';
11
11
 
12
- function PaginatorNavLink(props: Props): JSX.Element {
12
+ export default function PaginatorNavLink(props: Props): JSX.Element {
13
13
  const {permalink, title, subLabel} = props;
14
14
  return (
15
15
  <Link className="pagination-nav__link" to={permalink}>
@@ -18,5 +18,3 @@ function PaginatorNavLink(props: Props): JSX.Element {
18
18
  </Link>
19
19
  );
20
20
  }
21
-
22
- export default PaginatorNavLink;
@@ -6,7 +6,8 @@
6
6
  */
7
7
 
8
8
  // By default, the classic theme does not provide any SearchBar implementation
9
- // If you swizzled this file, it is your responsibility to provide an implementation
9
+ // If you swizzled this, it is your responsibility to provide an implementation
10
10
  // Tip: swizzle the SearchBar from the Algolia theme for inspiration:
11
11
  // npm run swizzle @docusaurus/theme-search-algolia SearchBar
12
+
12
13
  export {default} from '@docusaurus/Noop';
@@ -10,19 +10,25 @@ import React from 'react';
10
10
  import Head from '@docusaurus/Head';
11
11
  import type {Props} from '@theme/SearchMetadata';
12
12
 
13
- // Note: we don't couple this to Algolia/DocSearch on purpose
14
- // We may want to support other search engine plugins too
15
- // Search plugins should swizzle/override this comp to add their behavior
13
+ // Note: we bias toward using Algolia metadata on purpose
14
+ // Not doing so leads to confusion in the community,
15
+ // as it requires to first crawl the site with the Algolia plugin enabled first
16
+ // - https://github.com/facebook/docusaurus/issues/6693
17
+ // - https://github.com/facebook/docusaurus/issues/4555
16
18
  export default function SearchMetadata({
17
19
  locale,
18
20
  version,
19
21
  tag,
20
22
  }: Props): JSX.Element {
23
+ // Seems safe to consider here the locale is the language, as the existing
24
+ // docsearch:language filter is afaik a regular string-based filter
25
+ const language = locale;
26
+
21
27
  return (
22
28
  <Head>
23
- {locale && <meta name="docusaurus_locale" content={locale} />}
24
- {version && <meta name="docusaurus_version" content={version} />}
25
- {tag && <meta name="docusaurus_tag" content={tag} />}
29
+ {language && <meta name="docsearch:language" content={language} />}
30
+ {version && <meta name="docsearch:version" content={version} />}
31
+ {tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
26
32
  </Head>
27
33
  );
28
34
  }
@@ -18,7 +18,7 @@ function programmaticFocus(el: HTMLElement) {
18
18
  el.removeAttribute('tabindex');
19
19
  }
20
20
 
21
- function SkipToContent(): JSX.Element {
21
+ export default function SkipToContent(): JSX.Element {
22
22
  const containerRef = useRef<HTMLDivElement>(null);
23
23
  const {action} = useHistory();
24
24
  const handleSkip = (e: React.MouseEvent<HTMLAnchorElement>) => {
@@ -52,5 +52,3 @@ function SkipToContent(): JSX.Element {
52
52
  </div>
53
53
  );
54
54
  }
55
-
56
- export default SkipToContent;
@@ -7,16 +7,16 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import type {TOCProps} from '@theme/TOC';
10
+ import type {Props} from '@theme/TOC';
11
11
  import TOCItems from '@theme/TOCItems';
12
12
  import styles from './styles.module.css';
13
13
 
14
14
  // Using a custom className
15
- // This prevents TOC highlighting to highlight TOCInline/TOCCollapsible by mistake
15
+ // This prevents TOCInline/TOCCollapsible getting highlighted by mistake
16
16
  const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
17
17
  const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
18
18
 
19
- function TOC({className, ...props}: TOCProps): JSX.Element {
19
+ export default function TOC({className, ...props}: Props): JSX.Element {
20
20
  return (
21
21
  <div className={clsx(styles.tableOfContents, 'thin-scrollbar', className)}>
22
22
  <TOCItems
@@ -27,5 +27,3 @@ function TOC({className, ...props}: TOCProps): JSX.Element {
27
27
  </div>
28
28
  );
29
29
  }
30
-
31
- export default TOC;
@@ -11,14 +11,14 @@ import Translate from '@docusaurus/Translate';
11
11
  import {useCollapsible, Collapsible} from '@docusaurus/theme-common';
12
12
  import styles from './styles.module.css';
13
13
  import TOCItems from '@theme/TOCItems';
14
- import type {TOCCollapsibleProps} from '@theme/TOCCollapsible';
14
+ import type {Props} from '@theme/TOCCollapsible';
15
15
 
16
16
  export default function TOCCollapsible({
17
17
  toc,
18
18
  className,
19
19
  minHeadingLevel,
20
20
  maxHeadingLevel,
21
- }: TOCCollapsibleProps): JSX.Element {
21
+ }: Props): JSX.Element {
22
22
  const {collapsed, toggleCollapsed} = useCollapsible({
23
23
  initialState: true,
24
24
  });
@@ -6,15 +6,15 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import type {TOCInlineProps} from '@theme/TOCInline';
9
+ import type {Props} from '@theme/TOCInline';
10
10
  import styles from './styles.module.css';
11
11
  import TOCItems from '@theme/TOCItems';
12
12
 
13
- function TOCInline({
13
+ export default function TOCInline({
14
14
  toc,
15
15
  minHeadingLevel,
16
16
  maxHeadingLevel,
17
- }: TOCInlineProps): JSX.Element {
17
+ }: Props): JSX.Element {
18
18
  return (
19
19
  <div className={styles.tableOfContentsInline}>
20
20
  <TOCItems
@@ -27,5 +27,3 @@ function TOCInline({
27
27
  </div>
28
28
  );
29
29
  }
30
-
31
- export default TOCInline;
@@ -6,13 +6,13 @@
6
6
  */
7
7
 
8
8
  import React, {useMemo} from 'react';
9
- import type {TOCItemsProps} from '@theme/TOCItems';
10
- import type {TOCItem} from '@docusaurus/types';
9
+ import type {Props} from '@theme/TOCItems';
11
10
  import {
12
11
  type TOCHighlightConfig,
12
+ type TOCTreeNode,
13
13
  useThemeConfig,
14
- useTOCFilter,
15
14
  useTOCHighlight,
15
+ useFilteredAndTreeifiedTOC,
16
16
  } from '@docusaurus/theme-common';
17
17
 
18
18
  // Recursive component rendering the toc tree
@@ -23,7 +23,7 @@ function TOCItemList({
23
23
  linkClassName,
24
24
  isChild,
25
25
  }: {
26
- readonly toc: readonly TOCItem[];
26
+ readonly toc: readonly TOCTreeNode[];
27
27
  readonly className: string;
28
28
  readonly linkClassName: string | null;
29
29
  readonly isChild?: boolean;
@@ -62,7 +62,7 @@ export default function TOCItems({
62
62
  minHeadingLevel: minHeadingLevelOption,
63
63
  maxHeadingLevel: maxHeadingLevelOption,
64
64
  ...props
65
- }: TOCItemsProps): JSX.Element | null {
65
+ }: Props): JSX.Element | null {
66
66
  const themeConfig = useThemeConfig();
67
67
 
68
68
  const minHeadingLevel =
@@ -70,7 +70,11 @@ export default function TOCItems({
70
70
  const maxHeadingLevel =
71
71
  maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
72
72
 
73
- const tocFiltered = useTOCFilter({toc, minHeadingLevel, maxHeadingLevel});
73
+ const tocTree = useFilteredAndTreeifiedTOC({
74
+ toc,
75
+ minHeadingLevel,
76
+ maxHeadingLevel,
77
+ });
74
78
 
75
79
  const tocHighlightConfig: TOCHighlightConfig | undefined = useMemo(() => {
76
80
  if (linkClassName && linkActiveClassName) {
@@ -87,7 +91,7 @@ export default function TOCItems({
87
91
 
88
92
  return (
89
93
  <TOCItemList
90
- toc={tocFiltered}
94
+ toc={tocTree}
91
95
  className={className}
92
96
  linkClassName={linkClassName}
93
97
  {...props}
@@ -8,12 +8,14 @@
8
8
  import React from 'react';
9
9
  import type {Props} from '@theme/TabItem';
10
10
 
11
- function TabItem({children, hidden, className}: Props): JSX.Element {
11
+ export default function TabItem({
12
+ children,
13
+ hidden,
14
+ className,
15
+ }: Props): JSX.Element {
12
16
  return (
13
17
  <div role="tabpanel" {...{hidden, className}}>
14
18
  {children}
15
19
  </div>
16
20
  );
17
21
  }
18
-
19
- export default TabItem;
@@ -55,7 +55,7 @@ function TabsComponent(props: Props): JSX.Element {
55
55
  });
56
56
  const values =
57
57
  valuesProp ??
58
- // We only pick keys that we recognize. MDX would inject some keys by default
58
+ // Only pick keys that we recognize. MDX would inject some keys by default
59
59
  children.map(({props: {value, label, attributes}}) => ({
60
60
  value,
61
61
  label,
@@ -12,7 +12,7 @@ import type {Props} from '@theme/Tag';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- function Tag(props: Props): JSX.Element {
15
+ export default function Tag(props: Props): JSX.Element {
16
16
  const {permalink, name, count} = props;
17
17
 
18
18
  return (
@@ -27,5 +27,3 @@ function Tag(props: Props): JSX.Element {
27
27
  </Link>
28
28
  );
29
29
  }
30
-
31
- export default Tag;
@@ -28,7 +28,7 @@ function TagLetterEntryItem({letterEntry}: {letterEntry: TagLetterEntry}) {
28
28
  );
29
29
  }
30
30
 
31
- function TagsListByLetter({tags}: Props): JSX.Element {
31
+ export default function TagsListByLetter({tags}: Props): JSX.Element {
32
32
  const letterList = listTagsByLetters(tags);
33
33
  return (
34
34
  <section className="margin-vert--lg">
@@ -41,5 +41,3 @@ function TagsListByLetter({tags}: Props): JSX.Element {
41
41
  </section>
42
42
  );
43
43
  }
44
-
45
- export default TagsListByLetter;
@@ -14,7 +14,7 @@ import type {Props} from '@theme/ThemedImage';
14
14
 
15
15
  import styles from './styles.module.css';
16
16
 
17
- function ThemedImage(props: Props): JSX.Element {
17
+ export default function ThemedImage(props: Props): JSX.Element {
18
18
  const isBrowser = useIsBrowser();
19
19
  const {isDarkTheme} = useColorMode();
20
20
  const {sources, className, alt = '', ...propsRest} = props;
@@ -47,5 +47,3 @@ function ThemedImage(props: Props): JSX.Element {
47
47
  </>
48
48
  );
49
49
  }
50
-
51
- export default ThemedImage;