@docusaurus/theme-classic 2.4.1 → 3.0.0-beta.0

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 (174) hide show
  1. package/lib/getSwizzleConfig.js +107 -8
  2. package/lib/index.js +20 -6
  3. package/lib/nprogress.d.ts +1 -1
  4. package/lib/options.js +6 -2
  5. package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
  6. package/lib/theme/Admonition/Icon/Danger.js +17 -0
  7. package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
  8. package/lib/theme/Admonition/Icon/Info.js +17 -0
  9. package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
  10. package/lib/theme/Admonition/Icon/Note.js +17 -0
  11. package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
  12. package/lib/theme/Admonition/Icon/Tip.js +17 -0
  13. package/lib/theme/Admonition/Icon/Warning.d.ts +9 -0
  14. package/lib/theme/Admonition/Icon/Warning.js +17 -0
  15. package/lib/theme/Admonition/Layout/index.d.ts +9 -0
  16. package/lib/theme/Admonition/Layout/index.js +45 -0
  17. package/lib/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  18. package/lib/theme/Admonition/Type/Caution.d.ts +9 -0
  19. package/lib/theme/Admonition/Type/Caution.js +34 -0
  20. package/lib/theme/Admonition/Type/Danger.d.ts +9 -0
  21. package/lib/theme/Admonition/Type/Danger.js +32 -0
  22. package/lib/theme/Admonition/Type/Info.d.ts +9 -0
  23. package/lib/theme/Admonition/Type/Info.js +32 -0
  24. package/lib/theme/Admonition/Type/Note.d.ts +9 -0
  25. package/lib/theme/Admonition/Type/Note.js +32 -0
  26. package/lib/theme/Admonition/Type/Tip.d.ts +9 -0
  27. package/lib/theme/Admonition/Type/Tip.js +32 -0
  28. package/lib/theme/Admonition/Type/Warning.d.ts +9 -0
  29. package/lib/theme/Admonition/Type/Warning.js +32 -0
  30. package/lib/theme/Admonition/Types.d.ts +12 -0
  31. package/lib/theme/Admonition/Types.js +33 -0
  32. package/lib/theme/Admonition/index.d.ts +1 -1
  33. package/lib/theme/Admonition/index.js +12 -171
  34. package/lib/theme/BlogArchivePage/index.js +7 -2
  35. package/lib/theme/BlogLayout/index.js +1 -1
  36. package/lib/theme/BlogPostItem/Container/index.js +12 -3
  37. package/lib/theme/BlogPostItem/Header/Author/index.js +6 -1
  38. package/lib/theme/BlogPostPage/index.js +3 -1
  39. package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
  40. package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
  41. package/lib/theme/BlogTagsListPage/index.js +2 -1
  42. package/lib/theme/BlogTagsPostsPage/index.js +4 -2
  43. package/lib/theme/CodeBlock/Content/String.js +9 -2
  44. package/lib/theme/CodeBlock/CopyButton/index.js +0 -1
  45. package/lib/theme/DocBreadcrumbs/index.js +6 -2
  46. package/lib/theme/DocCard/index.js +8 -4
  47. package/lib/theme/DocItem/Layout/index.js +5 -0
  48. package/lib/theme/DocItem/index.js +1 -1
  49. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
  50. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
  51. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
  52. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
  53. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
  54. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +2 -2
  55. package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
  56. package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
  57. package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  58. package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
  59. package/lib/theme/DocRoot/index.js +31 -0
  60. package/lib/theme/DocSidebar/Desktop/index.d.ts +1 -1
  61. package/lib/theme/DocSidebar/Mobile/index.d.ts +1 -1
  62. package/lib/theme/DocSidebarItem/Category/index.js +24 -13
  63. package/lib/theme/DocSidebarItems/index.js +6 -4
  64. package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
  65. package/lib/theme/DocTagDocListPage/index.js +53 -39
  66. package/lib/theme/DocTagsListPage/index.d.ts +1 -1
  67. package/lib/theme/DocTagsListPage/index.js +26 -17
  68. package/lib/theme/DocVersionRoot/index.d.ts +10 -0
  69. package/lib/theme/DocVersionRoot/index.js +46 -0
  70. package/lib/theme/DocsRoot/index.d.ts +10 -0
  71. package/lib/theme/DocsRoot/index.js +18 -0
  72. package/lib/theme/EditThisPage/index.js +3 -6
  73. package/lib/theme/ErrorPageContent.js +3 -2
  74. package/lib/theme/MDXComponents/Code.js +2 -36
  75. package/lib/theme/MDXComponents/Details.js +1 -1
  76. package/lib/theme/MDXComponents/Pre.d.ts +2 -2
  77. package/lib/theme/MDXComponents/Pre.js +4 -11
  78. package/lib/theme/MDXComponents/Ul/index.js +4 -0
  79. package/lib/theme/MDXComponents/index.js +4 -3
  80. package/lib/theme/MDXPage/index.js +16 -4
  81. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
  82. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
  83. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
  84. package/lib/theme/NotFound/Content/index.d.ts +9 -0
  85. package/lib/theme/NotFound/Content/index.js +42 -0
  86. package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
  87. package/lib/theme/NotFound/index.js +25 -0
  88. package/lib/theme/SiteMetadata/index.js +30 -3
  89. package/lib/theme/TOCItems/Tree.js +3 -4
  90. package/lib/theme/Tabs/index.js +4 -2
  91. package/lib/theme/TagsListByLetter/index.js +4 -1
  92. package/lib/theme/ThemedImage/index.js +8 -24
  93. package/lib/theme/{MDXComponents/Head.d.ts → Unlisted/index.d.ts} +2 -2
  94. package/lib/theme/Unlisted/index.js +38 -0
  95. package/package.json +26 -26
  96. package/src/getSwizzleConfig.ts +116 -9
  97. package/src/index.ts +21 -6
  98. package/src/nprogress.ts +2 -1
  99. package/src/options.ts +7 -2
  100. package/src/theme/Admonition/Icon/Danger.tsx +20 -0
  101. package/src/theme/Admonition/Icon/Info.tsx +20 -0
  102. package/src/theme/Admonition/Icon/Note.tsx +20 -0
  103. package/src/theme/Admonition/Icon/Tip.tsx +20 -0
  104. package/src/theme/Admonition/Icon/Warning.tsx +20 -0
  105. package/src/theme/Admonition/Layout/index.tsx +57 -0
  106. package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  107. package/src/theme/Admonition/Type/Caution.tsx +39 -0
  108. package/src/theme/Admonition/Type/Danger.tsx +37 -0
  109. package/src/theme/Admonition/Type/Info.tsx +37 -0
  110. package/src/theme/Admonition/Type/Note.tsx +37 -0
  111. package/src/theme/Admonition/Type/Tip.tsx +37 -0
  112. package/src/theme/Admonition/Type/Warning.tsx +37 -0
  113. package/src/theme/Admonition/Types.tsx +38 -0
  114. package/src/theme/Admonition/index.tsx +13 -194
  115. package/src/theme/BlogArchivePage/index.tsx +7 -2
  116. package/src/theme/BlogLayout/index.tsx +1 -1
  117. package/src/theme/BlogPostItem/Container/index.tsx +12 -3
  118. package/src/theme/BlogPostItem/Header/Author/index.tsx +6 -1
  119. package/src/theme/BlogPostPage/index.tsx +3 -1
  120. package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
  121. package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
  122. package/src/theme/BlogTagsListPage/index.tsx +2 -1
  123. package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
  124. package/src/theme/CodeBlock/Content/String.tsx +11 -2
  125. package/src/theme/CodeBlock/CopyButton/index.tsx +0 -1
  126. package/src/theme/DocBreadcrumbs/index.tsx +6 -2
  127. package/src/theme/DocCard/index.tsx +11 -6
  128. package/src/theme/DocItem/Layout/index.tsx +5 -0
  129. package/src/theme/DocItem/index.tsx +1 -1
  130. package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
  131. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
  132. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +3 -3
  133. package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
  134. package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  135. package/src/theme/DocRoot/index.tsx +34 -0
  136. package/src/theme/DocSidebarItem/Category/index.tsx +25 -12
  137. package/src/theme/DocSidebarItems/index.tsx +6 -4
  138. package/src/theme/DocTagDocListPage/index.tsx +60 -39
  139. package/src/theme/DocTagsListPage/index.tsx +33 -17
  140. package/src/theme/DocVersionRoot/index.tsx +51 -0
  141. package/src/theme/DocsRoot/index.tsx +22 -0
  142. package/src/theme/EditThisPage/index.tsx +3 -6
  143. package/src/theme/ErrorPageContent.tsx +3 -2
  144. package/src/theme/MDXComponents/Code.tsx +2 -39
  145. package/src/theme/MDXComponents/Details.tsx +1 -2
  146. package/src/theme/MDXComponents/Pre.tsx +5 -13
  147. package/src/theme/MDXComponents/Ul/index.tsx +5 -1
  148. package/src/theme/MDXComponents/index.tsx +11 -10
  149. package/src/theme/MDXPage/index.tsx +16 -4
  150. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
  151. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
  152. package/src/theme/NotFound/Content/index.tsx +45 -0
  153. package/src/theme/NotFound/index.tsx +27 -0
  154. package/src/theme/SiteMetadata/index.tsx +36 -3
  155. package/src/theme/SkipToContent/index.tsx +0 -1
  156. package/src/theme/TOCItems/Tree.tsx +3 -4
  157. package/src/theme/Tabs/index.tsx +4 -2
  158. package/src/theme/TagsListByLetter/index.tsx +4 -2
  159. package/src/theme/ThemedImage/index.tsx +8 -31
  160. package/src/theme/Unlisted/index.tsx +42 -0
  161. package/src/theme/prism-include-languages.ts +2 -1
  162. package/src/theme-classic.d.ts +146 -21
  163. package/lib/theme/DocPage/index.js +0 -67
  164. package/lib/theme/MDXComponents/Head.js +0 -23
  165. package/lib/theme/NotFound.js +0 -52
  166. package/src/theme/DocPage/index.tsx +0 -71
  167. package/src/theme/MDXComponents/Head.tsx +0 -29
  168. package/src/theme/NotFound.tsx +0 -54
  169. /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  170. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  171. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
  172. /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  173. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  174. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
@@ -15,6 +15,7 @@ import {
15
15
  import Layout from '@theme/Layout';
16
16
  import MDXContent from '@theme/MDXContent';
17
17
  import TOC from '@theme/TOC';
18
+ import Unlisted from '@theme/Unlisted';
18
19
  import type {Props} from '@theme/MDXPage';
19
20
 
20
21
  import styles from './styles.module.css';
@@ -22,10 +23,15 @@ import styles from './styles.module.css';
22
23
  export default function MDXPage(props: Props): JSX.Element {
23
24
  const {content: MDXPageContent} = props;
24
25
  const {
25
- metadata: {title, description, frontMatter},
26
+ metadata: {title, description, frontMatter, unlisted},
27
+ assets,
26
28
  } = MDXPageContent;
27
- const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
28
- frontMatter;
29
+ const {
30
+ keywords,
31
+ wrapperClassName,
32
+ hide_table_of_contents: hideTableOfContents,
33
+ } = frontMatter;
34
+ const image = assets.image ?? frontMatter.image;
29
35
 
30
36
  return (
31
37
  <HtmlClassNameProvider
@@ -33,11 +39,17 @@ export default function MDXPage(props: Props): JSX.Element {
33
39
  wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
34
40
  ThemeClassNames.page.mdxPage,
35
41
  )}>
36
- <PageMetadata title={title} description={description} />
37
42
  <Layout>
43
+ <PageMetadata
44
+ title={title}
45
+ description={description}
46
+ keywords={keywords}
47
+ image={image}
48
+ />
38
49
  <main className="container container--fluid margin-vert--lg">
39
50
  <div className={clsx('row', styles.mdxPageWrapper)}>
40
51
  <div className={clsx('col', !hideTableOfContents && 'col--8')}>
52
+ {unlisted && <Unlisted />}
41
53
  <article>
42
54
  <MDXContent>
43
55
  <MDXPageContent />
@@ -19,9 +19,10 @@ export default function DocNavbarItem({
19
19
  }: Props): JSX.Element | null {
20
20
  const {activeDoc} = useActiveDocContext(docsPluginId);
21
21
  const doc = useLayoutDoc(docId, docsPluginId);
22
+ const pageActive = activeDoc?.path === doc?.path;
22
23
 
23
- // Draft items are not displayed in the navbar.
24
- if (doc === null) {
24
+ // Draft and unlisted items are not displayed in the navbar.
25
+ if (doc === null || (doc.unlisted && !pageActive)) {
25
26
  return null;
26
27
  }
27
28
 
@@ -30,7 +31,7 @@ export default function DocNavbarItem({
30
31
  exact
31
32
  {...props}
32
33
  isActive={() =>
33
- activeDoc?.path === doc.path ||
34
+ pageActive ||
34
35
  (!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
35
36
  }
36
37
  label={staticLabel ?? doc.id}
@@ -21,6 +21,7 @@ export default function LocaleDropdownNavbarItem({
21
21
  mobile,
22
22
  dropdownItemsBefore,
23
23
  dropdownItemsAfter,
24
+ queryString = '',
24
25
  ...props
25
26
  }: Props): JSX.Element {
26
27
  const {
@@ -35,7 +36,7 @@ export default function LocaleDropdownNavbarItem({
35
36
  fullyQualified: false,
36
37
  })}`;
37
38
  // preserve ?search#hash suffix on locale switches
38
- const to = `${baseTo}${search}${hash}`;
39
+ const to = `${baseTo}${search}${hash}${queryString}`;
39
40
  return {
40
41
  label: localeConfigs[locale]!.label,
41
42
  lang: localeConfigs[locale]!.htmlLang,
@@ -0,0 +1,45 @@
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 Translate from '@docusaurus/Translate';
11
+ import type {Props} from '@theme/NotFound/Content';
12
+ import Heading from '@theme/Heading';
13
+
14
+ export default function NotFoundContent({className}: Props): JSX.Element {
15
+ return (
16
+ <main className={clsx('container margin-vert--xl', className)}>
17
+ <div className="row">
18
+ <div className="col col--6 col--offset-3">
19
+ <Heading as="h1" className="hero__title">
20
+ <Translate
21
+ id="theme.NotFound.title"
22
+ description="The title of the 404 page">
23
+ Page Not Found
24
+ </Translate>
25
+ </Heading>
26
+ <p>
27
+ <Translate
28
+ id="theme.NotFound.p1"
29
+ description="The first paragraph of the 404 page">
30
+ We could not find what you were looking for.
31
+ </Translate>
32
+ </p>
33
+ <p>
34
+ <Translate
35
+ id="theme.NotFound.p2"
36
+ description="The 2nd paragraph of the 404 page">
37
+ Please contact the owner of the site that linked you to the
38
+ original URL and let them know their link is broken.
39
+ </Translate>
40
+ </p>
41
+ </div>
42
+ </div>
43
+ </main>
44
+ );
45
+ }
@@ -0,0 +1,27 @@
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 {translate} from '@docusaurus/Translate';
10
+ import {PageMetadata} from '@docusaurus/theme-common';
11
+ import Layout from '@theme/Layout';
12
+ import NotFoundContent from '@theme/NotFound/Content';
13
+
14
+ export default function Index(): JSX.Element {
15
+ const title = translate({
16
+ id: 'theme.NotFound.title',
17
+ message: 'Page Not Found',
18
+ });
19
+ return (
20
+ <>
21
+ <PageMetadata title={title} />
22
+ <Layout>
23
+ <NotFoundContent />
24
+ </Layout>
25
+ </>
26
+ );
27
+ }
@@ -16,6 +16,7 @@ import {
16
16
  keyboardFocusedClassName,
17
17
  } from '@docusaurus/theme-common/internal';
18
18
  import {useLocation} from '@docusaurus/router';
19
+ import {applyTrailingSlash} from '@docusaurus/utils-common';
19
20
  import SearchMetadata from '@theme/SearchMetadata';
20
21
 
21
22
  // TODO move to SiteMetadataDefaults or theme-common ?
@@ -24,10 +25,19 @@ import SearchMetadata from '@theme/SearchMetadata';
24
25
  // See https://github.com/facebook/docusaurus/issues/3317
25
26
  function AlternateLangHeaders(): JSX.Element {
26
27
  const {
27
- i18n: {defaultLocale, localeConfigs},
28
+ i18n: {currentLocale, defaultLocale, localeConfigs},
28
29
  } = useDocusaurusContext();
29
30
  const alternatePageUtils = useAlternatePageUtils();
30
31
 
32
+ const currentHtmlLang = localeConfigs[currentLocale]!.htmlLang;
33
+
34
+ // HTML lang is a BCP 47 tag, but the Open Graph protocol requires
35
+ // using underscores instead of dashes.
36
+ // See https://ogp.me/#optional
37
+ // See https://en.wikipedia.org/wiki/IETF_language_tag)
38
+ const bcp47ToOpenGraphLocale = (code: string): string =>
39
+ code.replace('-', '_');
40
+
31
41
  // Note: it is fine to use both "x-default" and "en" to target the same url
32
42
  // See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
33
43
  return (
@@ -51,6 +61,20 @@ function AlternateLangHeaders(): JSX.Element {
51
61
  })}
52
62
  hrefLang="x-default"
53
63
  />
64
+
65
+ <meta
66
+ property="og:locale"
67
+ content={bcp47ToOpenGraphLocale(currentHtmlLang)}
68
+ />
69
+ {Object.values(localeConfigs)
70
+ .filter((config) => currentHtmlLang !== config.htmlLang)
71
+ .map((config) => (
72
+ <meta
73
+ key={`meta-og-${config.htmlLang}`}
74
+ property="og:locale:alternate"
75
+ content={bcp47ToOpenGraphLocale(config.htmlLang)}
76
+ />
77
+ ))}
54
78
  </Head>
55
79
  );
56
80
  }
@@ -58,10 +82,19 @@ function AlternateLangHeaders(): JSX.Element {
58
82
  // Default canonical url inferred from current page location pathname
59
83
  function useDefaultCanonicalUrl() {
60
84
  const {
61
- siteConfig: {url: siteUrl},
85
+ siteConfig: {url: siteUrl, baseUrl, trailingSlash},
62
86
  } = useDocusaurusContext();
87
+
88
+ // TODO using useLocation().pathname is not a super idea
89
+ // See https://github.com/facebook/docusaurus/issues/9170
63
90
  const {pathname} = useLocation();
64
- return siteUrl + useBaseUrl(pathname);
91
+
92
+ const canonicalPathname = applyTrailingSlash(useBaseUrl(pathname), {
93
+ trailingSlash,
94
+ baseUrl,
95
+ });
96
+
97
+ return siteUrl + canonicalPathname;
65
98
  }
66
99
 
67
100
  // TODO move to SiteMetadataDefaults or theme-common ?
@@ -7,7 +7,6 @@
7
7
 
8
8
  import React from 'react';
9
9
  import {SkipToContentLink} from '@docusaurus/theme-common';
10
-
11
10
  import styles from './styles.module.css';
12
11
 
13
12
  export default function SkipToContent(): JSX.Element {
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import Link from '@docusaurus/Link';
9
10
  import type {Props} from '@theme/TOCItems/Tree';
10
11
 
11
12
  // Recursive component rendering the toc tree
@@ -22,12 +23,10 @@ function TOCItemTree({
22
23
  <ul className={isChild ? undefined : className}>
23
24
  {toc.map((heading) => (
24
25
  <li key={heading.id}>
25
- {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
26
- <a
27
- href={`#${heading.id}`}
26
+ <Link
27
+ to={`#${heading.id}`}
28
28
  className={linkClassName ?? undefined}
29
29
  // Developer provided the HTML, so assume it's safe.
30
- // eslint-disable-next-line react/no-danger
31
30
  dangerouslySetInnerHTML={{__html: heading.value}}
32
31
  />
33
32
  <TOCItemTree
@@ -10,6 +10,7 @@ import clsx from 'clsx';
10
10
  import {
11
11
  useScrollPositionBlocker,
12
12
  useTabs,
13
+ sanitizeTabsChildren,
13
14
  type TabItemProps,
14
15
  } from '@docusaurus/theme-common/internal';
15
16
  import useIsBrowser from '@docusaurus/useIsBrowser';
@@ -152,7 +153,8 @@ export default function Tabs(props: Props): JSX.Element {
152
153
  // Remount tabs after hydration
153
154
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
154
155
  key={String(isBrowser)}
155
- {...props}
156
- />
156
+ {...props}>
157
+ {sanitizeTabsChildren(props.children)}
158
+ </TabsComponent>
157
159
  );
158
160
  }
@@ -9,13 +9,15 @@ import React from 'react';
9
9
  import {listTagsByLetters, type TagLetterEntry} from '@docusaurus/theme-common';
10
10
  import Tag from '@theme/Tag';
11
11
  import type {Props} from '@theme/TagsListByLetter';
12
-
12
+ import Heading from '@theme/Heading';
13
13
  import styles from './styles.module.css';
14
14
 
15
15
  function TagLetterEntryItem({letterEntry}: {letterEntry: TagLetterEntry}) {
16
16
  return (
17
17
  <article>
18
- <h2>{letterEntry.letter}</h2>
18
+ <Heading as="h2" id={letterEntry.letter}>
19
+ {letterEntry.letter}
20
+ </Heading>
19
21
  <ul className="padding--none">
20
22
  {letterEntry.tags.map((tag) => (
21
23
  <li key={tag.permalink} className={styles.tag}>
@@ -6,44 +6,21 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
- import useIsBrowser from '@docusaurus/useIsBrowser';
11
- import {useColorMode} from '@docusaurus/theme-common';
9
+ import {ThemedComponent} from '@docusaurus/theme-common';
12
10
  import type {Props} from '@theme/ThemedImage';
13
11
 
14
- import styles from './styles.module.css';
15
-
16
12
  export default function ThemedImage(props: Props): JSX.Element {
17
- const isBrowser = useIsBrowser();
18
- const {colorMode} = useColorMode();
19
- const {sources, className, alt, ...propsRest} = props;
20
-
21
- type SourceName = keyof Props['sources'];
22
-
23
- const clientThemes: SourceName[] =
24
- colorMode === 'dark' ? ['dark'] : ['light'];
25
-
26
- const renderedSourceNames: SourceName[] = isBrowser
27
- ? clientThemes
28
- : // We need to render both images on the server to avoid flash
29
- // See https://github.com/facebook/docusaurus/pull/3730
30
- ['light', 'dark'];
31
-
13
+ const {sources, className: parentClassName, alt, ...propsRest} = props;
32
14
  return (
33
- <>
34
- {renderedSourceNames.map((sourceName) => (
15
+ <ThemedComponent className={parentClassName}>
16
+ {({theme, className}) => (
35
17
  <img
36
- key={sourceName}
37
- src={sources[sourceName]}
18
+ src={sources[theme]}
38
19
  alt={alt}
39
- className={clsx(
40
- styles.themedImage,
41
- styles[`themedImage--${sourceName}`],
42
- className,
43
- )}
20
+ className={className}
44
21
  {...propsRest}
45
22
  />
46
- ))}
47
- </>
23
+ )}
24
+ </ThemedComponent>
48
25
  );
49
26
  }
@@ -0,0 +1,42 @@
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 {
11
+ ThemeClassNames,
12
+ UnlistedBannerTitle,
13
+ UnlistedBannerMessage,
14
+ UnlistedMetadata,
15
+ } from '@docusaurus/theme-common';
16
+ import Admonition from '@theme/Admonition';
17
+ import type {Props} from '@theme/Unlisted';
18
+
19
+ function UnlistedBanner({className}: Props) {
20
+ return (
21
+ <Admonition
22
+ type="caution"
23
+ title={<UnlistedBannerTitle />}
24
+ className={clsx(className, ThemeClassNames.common.unlistedBanner)}>
25
+ <UnlistedBannerMessage />
26
+ </Admonition>
27
+ );
28
+ }
29
+
30
+ export default function Unlisted(props: Props): JSX.Element | null {
31
+ return (
32
+ <>
33
+ {/*
34
+ Unlisted metadata declared here for simplicity.
35
+ Ensures we never forget to add the correct noindex metadata.
36
+ Also gives a central place for user to swizzle override default metadata.
37
+ */}
38
+ <UnlistedMetadata />
39
+ <UnlistedBanner {...props} />
40
+ </>
41
+ );
42
+ }
@@ -7,6 +7,7 @@
7
7
 
8
8
  import siteConfig from '@generated/docusaurus.config';
9
9
  import type * as PrismNamespace from 'prismjs';
10
+ import type {Optional} from 'utility-types';
10
11
 
11
12
  export default function prismIncludeLanguages(
12
13
  PrismObject: typeof PrismNamespace,
@@ -29,5 +30,5 @@ export default function prismIncludeLanguages(
29
30
  require(`prismjs/components/prism-${lang}`);
30
31
  });
31
32
 
32
- delete (globalThis as Global & {Prism?: typeof PrismNamespace}).Prism;
33
+ delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism;
33
34
  }
@@ -44,13 +44,123 @@ declare module '@theme/Admonition' {
44
44
 
45
45
  export interface Props {
46
46
  readonly children: ReactNode;
47
- readonly type: 'note' | 'tip' | 'danger' | 'info' | 'caution';
47
+ readonly type: string;
48
48
  readonly icon?: ReactNode;
49
49
  readonly title?: ReactNode;
50
+ readonly className?: string;
50
51
  }
52
+
51
53
  export default function Admonition(props: Props): JSX.Element;
52
54
  }
53
55
 
56
+ declare module '@theme/Admonition/Type/Note' {
57
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
58
+
59
+ export interface Props extends AdmonitionProps {}
60
+ export default function AdmonitionTypeNote(props: Props): JSX.Element;
61
+ }
62
+
63
+ declare module '@theme/Admonition/Type/Info' {
64
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
65
+
66
+ export interface Props extends AdmonitionProps {}
67
+ export default function AdmonitionTypeInfo(props: Props): JSX.Element;
68
+ }
69
+
70
+ declare module '@theme/Admonition/Type/Tip' {
71
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
72
+
73
+ export interface Props extends AdmonitionProps {}
74
+ export default function AdmonitionTypeTip(props: Props): JSX.Element;
75
+ }
76
+
77
+ // TODO remove before v4: Caution replaced by Warning
78
+ // see https://github.com/facebook/docusaurus/issues/7558
79
+ declare module '@theme/Admonition/Type/Caution' {
80
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
81
+
82
+ export interface Props extends AdmonitionProps {}
83
+ export default function AdmonitionTypeCaution(props: Props): JSX.Element;
84
+ }
85
+
86
+ declare module '@theme/Admonition/Type/Warning' {
87
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
88
+
89
+ export interface Props extends AdmonitionProps {}
90
+ export default function AdmonitionTypeWarning(props: Props): JSX.Element;
91
+ }
92
+
93
+ declare module '@theme/Admonition/Type/Danger' {
94
+ import type {Props as AdmonitionProps} from '@theme/Admonition';
95
+
96
+ export interface Props extends AdmonitionProps {}
97
+ export default function AdmonitionTypeDanger(props: Props): JSX.Element;
98
+ }
99
+
100
+ declare module '@theme/Admonition/Types' {
101
+ import type {ComponentType} from 'react';
102
+ import type {Props} from '@theme/Admonition';
103
+
104
+ const AdmonitionTypes: {
105
+ [admonitionType: string]: ComponentType<Props>;
106
+ };
107
+
108
+ export default AdmonitionTypes;
109
+ }
110
+
111
+ declare module '@theme/Admonition/Layout' {
112
+ import type {ReactNode} from 'react';
113
+
114
+ export interface Props {
115
+ readonly children: ReactNode;
116
+ readonly type: string;
117
+ readonly icon?: ReactNode;
118
+ readonly title?: ReactNode;
119
+ readonly className?: string;
120
+ }
121
+ export default function AdmonitionLayout(props: Props): JSX.Element;
122
+ }
123
+
124
+ declare module '@theme/Admonition/Icon/Note' {
125
+ import type {ComponentProps} from 'react';
126
+
127
+ export interface Props extends ComponentProps<'svg'> {}
128
+
129
+ export default function AdmonitionIconNote(props: Props): JSX.Element;
130
+ }
131
+
132
+ declare module '@theme/Admonition/Icon/Tip' {
133
+ import type {ComponentProps} from 'react';
134
+
135
+ export interface Props extends ComponentProps<'svg'> {}
136
+
137
+ export default function AdmonitionIconTip(props: Props): JSX.Element;
138
+ }
139
+
140
+ declare module '@theme/Admonition/Icon/Warning' {
141
+ import type {ComponentProps} from 'react';
142
+
143
+ export interface Props extends ComponentProps<'svg'> {}
144
+
145
+ export default function AdmonitionIconWarning(props: Props): JSX.Element;
146
+ }
147
+
148
+ declare module '@theme/Admonition/Icon/Danger' {
149
+ import type {ComponentProps} from 'react';
150
+
151
+ export interface Props extends ComponentProps<'svg'> {}
152
+
153
+ export default function AdmonitionIconDanger(props: Props): JSX.Element;
154
+ }
155
+
156
+ declare module '@theme/Admonition/Icon/Info' {
157
+ import type {ComponentProps} from 'react';
158
+
159
+ export interface Props extends ComponentProps<'svg'> {}
160
+
161
+ export default function AdmonitionIconInfo(props: Props): JSX.Element;
162
+ }
163
+
54
164
  declare module '@theme/AnnouncementBar' {
55
165
  export default function AnnouncementBar(): JSX.Element | null;
56
166
  }
@@ -379,17 +489,17 @@ declare module '@theme/DocItem/Footer' {
379
489
  export default function DocItemFooter(): JSX.Element;
380
490
  }
381
491
 
382
- declare module '@theme/DocPage/Layout' {
492
+ declare module '@theme/DocRoot/Layout' {
383
493
  import type {ReactNode} from 'react';
384
494
 
385
495
  export interface Props {
386
496
  readonly children: ReactNode;
387
497
  }
388
498
 
389
- export default function DocPageLayout(props: Props): JSX.Element;
499
+ export default function DocRootLayout(props: Props): JSX.Element;
390
500
  }
391
501
 
392
- declare module '@theme/DocPage/Layout/Sidebar' {
502
+ declare module '@theme/DocRoot/Layout/Sidebar' {
393
503
  import type {Dispatch, SetStateAction} from 'react';
394
504
  import type {PropSidebar} from '@docusaurus/plugin-content-docs';
395
505
 
@@ -399,20 +509,20 @@ declare module '@theme/DocPage/Layout/Sidebar' {
399
509
  readonly setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
400
510
  }
401
511
 
402
- export default function DocPageLayoutSidebar(props: Props): JSX.Element;
512
+ export default function DocRootLayoutSidebar(props: Props): JSX.Element;
403
513
  }
404
514
 
405
- declare module '@theme/DocPage/Layout/Sidebar/ExpandButton' {
515
+ declare module '@theme/DocRoot/Layout/Sidebar/ExpandButton' {
406
516
  export interface Props {
407
517
  toggleSidebar: () => void;
408
518
  }
409
519
 
410
- export default function DocPageLayoutSidebarExpandButton(
520
+ export default function DocRootLayoutSidebarExpandButton(
411
521
  props: Props,
412
522
  ): JSX.Element;
413
523
  }
414
524
 
415
- declare module '@theme/DocPage/Layout/Main' {
525
+ declare module '@theme/DocRoot/Layout/Main' {
416
526
  import type {ReactNode} from 'react';
417
527
 
418
528
  export interface Props {
@@ -420,7 +530,7 @@ declare module '@theme/DocPage/Layout/Main' {
420
530
  readonly children: ReactNode;
421
531
  }
422
532
 
423
- export default function DocPageLayoutMain(props: Props): JSX.Element;
533
+ export default function DocRootLayoutMain(props: Props): JSX.Element;
424
534
  }
425
535
 
426
536
  declare module '@theme/DocPaginator' {
@@ -662,6 +772,14 @@ declare module '@theme/Heading' {
662
772
  export default function Heading(props: Props): JSX.Element;
663
773
  }
664
774
 
775
+ declare module '@theme/NotFound/Content' {
776
+ export interface Props {
777
+ readonly className?: string;
778
+ }
779
+
780
+ export default function NotFoundContent(props: Props): JSX.Element;
781
+ }
782
+
665
783
  declare module '@theme/Layout' {
666
784
  import type {ReactNode} from 'react';
667
785
 
@@ -752,14 +870,6 @@ declare module '@theme/MDXComponents/Img' {
752
870
  export default function MDXImg(props: Props): JSX.Element;
753
871
  }
754
872
 
755
- declare module '@theme/MDXComponents/Head' {
756
- import type {ComponentProps} from 'react';
757
-
758
- export interface Props extends ComponentProps<'head'> {}
759
-
760
- export default function MDXHead(props: Props): JSX.Element;
761
- }
762
-
763
873
  declare module '@theme/MDXComponents/Heading' {
764
874
  import type {ComponentProps} from 'react';
765
875
  import type Heading from '@theme/Heading';
@@ -780,7 +890,6 @@ declare module '@theme/MDXComponents/Pre' {
780
890
  declare module '@theme/MDXComponents' {
781
891
  import type {ComponentType, ComponentProps} from 'react';
782
892
 
783
- import type MDXHead from '@theme/MDXComponents/Head';
784
893
  import type MDXCode from '@theme/MDXComponents/Code';
785
894
  import type MDXA from '@theme/MDXComponents/A';
786
895
  import type MDXPre from '@theme/MDXComponents/Pre';
@@ -789,13 +898,20 @@ declare module '@theme/MDXComponents' {
789
898
  import type MDXImg from '@theme/MDXComponents/Img';
790
899
  import type Admonition from '@theme/Admonition';
791
900
  import type Mermaid from '@theme/Mermaid';
901
+ import type Head from '@docusaurus/Head';
792
902
 
793
- export type MDXComponentsObject = {
794
- readonly head: typeof MDXHead;
903
+ import type {MDXProvider} from '@mdx-js/react';
904
+
905
+ type MDXComponentsBase = ComponentProps<typeof MDXProvider>['components'];
906
+
907
+ export type MDXComponentsObject = MDXComponentsBase & {
908
+ readonly Head: typeof Head;
909
+ readonly details: typeof MDXDetails;
910
+
911
+ readonly Details: typeof MDXDetails;
795
912
  readonly code: typeof MDXCode;
796
913
  readonly a: typeof MDXA;
797
914
  readonly pre: typeof MDXPre;
798
- readonly details: typeof MDXDetails;
799
915
  readonly ul: typeof MDXUl;
800
916
  readonly img: typeof MDXImg;
801
917
  readonly h1: (props: ComponentProps<'h1'>) => JSX.Element;
@@ -963,6 +1079,7 @@ declare module '@theme/NavbarItem/LocaleDropdownNavbarItem' {
963
1079
  export interface Props extends DropdownNavbarItemProps {
964
1080
  readonly dropdownItemsBefore: LinkLikeNavbarItemProps[];
965
1081
  readonly dropdownItemsAfter: LinkLikeNavbarItemProps[];
1082
+ readonly queryString?: string;
966
1083
  }
967
1084
 
968
1085
  export default function LocaleDropdownNavbarItem(props: Props): JSX.Element;
@@ -1389,6 +1506,14 @@ declare module '@theme/Tag' {
1389
1506
  export default function Tag(props: Props): JSX.Element;
1390
1507
  }
1391
1508
 
1509
+ declare module '@theme/Unlisted' {
1510
+ export interface Props {
1511
+ className?: string;
1512
+ }
1513
+
1514
+ export default function Unlisted(props: Props): JSX.Element;
1515
+ }
1516
+
1392
1517
  declare module '@theme/prism-include-languages' {
1393
1518
  import type * as PrismNamespace from 'prismjs';
1394
1519