@docusaurus/theme-classic 2.4.0 → 3.0.0-alpha.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 (170) hide show
  1. package/lib/getSwizzleConfig.js +99 -7
  2. package/lib/index.js +20 -6
  3. package/lib/nprogress.d.ts +1 -1
  4. package/lib/options.js +1 -0
  5. package/lib/theme/Admonition/Icon/Caution.d.ts +9 -0
  6. package/lib/theme/Admonition/Icon/Caution.js +17 -0
  7. package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
  8. package/lib/theme/Admonition/Icon/Danger.js +17 -0
  9. package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
  10. package/lib/theme/Admonition/Icon/Info.js +17 -0
  11. package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
  12. package/lib/theme/Admonition/Icon/Note.js +17 -0
  13. package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
  14. package/lib/theme/Admonition/Icon/Tip.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 +32 -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/Types.d.ts +12 -0
  29. package/lib/theme/Admonition/Types.js +33 -0
  30. package/lib/theme/Admonition/index.d.ts +1 -1
  31. package/lib/theme/Admonition/index.js +12 -171
  32. package/lib/theme/BlogArchivePage/index.js +7 -2
  33. package/lib/theme/BlogPostPage/index.js +3 -1
  34. package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
  35. package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
  36. package/lib/theme/BlogTagsListPage/index.js +2 -1
  37. package/lib/theme/BlogTagsPostsPage/index.js +4 -2
  38. package/lib/theme/CodeBlock/CopyButton/index.js +4 -6
  39. package/lib/theme/CodeBlock/WordWrapButton/index.js +2 -9
  40. package/lib/theme/DocBreadcrumbs/index.js +6 -2
  41. package/lib/theme/DocCard/index.js +8 -4
  42. package/lib/theme/DocItem/Layout/index.js +5 -0
  43. package/lib/theme/DocPaginator/index.js +1 -1
  44. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
  45. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
  46. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
  47. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
  48. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
  49. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +8 -3
  50. package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
  51. package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
  52. package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  53. package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
  54. package/lib/theme/DocRoot/index.js +31 -0
  55. package/lib/theme/DocSidebarItem/Category/index.js +3 -3
  56. package/lib/theme/DocSidebarItems/index.js +6 -4
  57. package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
  58. package/lib/theme/DocTagDocListPage/index.js +53 -39
  59. package/lib/theme/DocTagsListPage/index.d.ts +1 -1
  60. package/lib/theme/DocTagsListPage/index.js +26 -17
  61. package/lib/theme/DocVersionRoot/index.d.ts +10 -0
  62. package/lib/theme/DocVersionRoot/index.js +46 -0
  63. package/lib/theme/DocsRoot/index.d.ts +10 -0
  64. package/lib/theme/DocsRoot/index.js +18 -0
  65. package/lib/theme/EditThisPage/index.js +3 -6
  66. package/lib/theme/ErrorPageContent.js +3 -2
  67. package/lib/theme/{MDXComponents/Head.d.ts → Icon/Copy/index.d.ts} +2 -2
  68. package/lib/theme/Icon/Copy/index.js +17 -0
  69. package/lib/theme/Icon/Success/index.d.ts +9 -0
  70. package/lib/theme/Icon/Success/index.js +17 -0
  71. package/lib/theme/Icon/WordWrap/index.d.ts +9 -0
  72. package/lib/theme/Icon/WordWrap/index.js +17 -0
  73. package/lib/theme/MDXComponents/Code.js +2 -36
  74. package/lib/theme/MDXComponents/Details.js +1 -1
  75. package/lib/theme/MDXComponents/Pre.d.ts +2 -2
  76. package/lib/theme/MDXComponents/Pre.js +4 -11
  77. package/lib/theme/MDXComponents/index.js +3 -3
  78. package/lib/theme/MDXContent/index.js +1 -0
  79. package/lib/theme/MDXPage/index.js +16 -4
  80. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
  81. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
  82. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
  83. package/lib/theme/NotFound/Content/index.d.ts +9 -0
  84. package/lib/theme/NotFound/Content/index.js +42 -0
  85. package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
  86. package/lib/theme/NotFound/index.js +25 -0
  87. package/lib/theme/TOCItems/Tree.js +3 -4
  88. package/lib/theme/Tabs/index.js +4 -2
  89. package/lib/theme/TagsListByLetter/index.js +4 -1
  90. package/lib/theme/ThemedImage/index.js +8 -24
  91. package/lib/theme/Unlisted/index.d.ts +9 -0
  92. package/lib/theme/Unlisted/index.js +38 -0
  93. package/package.json +24 -24
  94. package/src/getSwizzleConfig.ts +107 -8
  95. package/src/index.ts +21 -6
  96. package/src/nprogress.ts +2 -1
  97. package/src/options.ts +1 -0
  98. package/src/theme/Admonition/Icon/Caution.tsx +20 -0
  99. package/src/theme/Admonition/Icon/Danger.tsx +20 -0
  100. package/src/theme/Admonition/Icon/Info.tsx +20 -0
  101. package/src/theme/Admonition/Icon/Note.tsx +20 -0
  102. package/src/theme/Admonition/Icon/Tip.tsx +20 -0
  103. package/src/theme/Admonition/Layout/index.tsx +57 -0
  104. package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  105. package/src/theme/Admonition/Type/Caution.tsx +37 -0
  106. package/src/theme/Admonition/Type/Danger.tsx +37 -0
  107. package/src/theme/Admonition/Type/Info.tsx +37 -0
  108. package/src/theme/Admonition/Type/Note.tsx +37 -0
  109. package/src/theme/Admonition/Type/Tip.tsx +37 -0
  110. package/src/theme/Admonition/Types.tsx +38 -0
  111. package/src/theme/Admonition/index.tsx +13 -194
  112. package/src/theme/BlogArchivePage/index.tsx +7 -2
  113. package/src/theme/BlogPostPage/index.tsx +3 -1
  114. package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
  115. package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
  116. package/src/theme/BlogTagsListPage/index.tsx +2 -1
  117. package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
  118. package/src/theme/CodeBlock/CopyButton/index.tsx +4 -6
  119. package/src/theme/CodeBlock/WordWrapButton/index.tsx +2 -9
  120. package/src/theme/DocBreadcrumbs/index.tsx +6 -2
  121. package/src/theme/DocCard/index.tsx +11 -6
  122. package/src/theme/DocItem/Layout/index.tsx +5 -0
  123. package/src/theme/DocPaginator/index.tsx +1 -1
  124. package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
  125. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
  126. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +9 -4
  127. package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
  128. package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  129. package/src/theme/DocRoot/index.tsx +34 -0
  130. package/src/theme/DocSidebarItem/Category/index.tsx +3 -3
  131. package/src/theme/DocSidebarItems/index.tsx +6 -4
  132. package/src/theme/DocTagDocListPage/index.tsx +60 -39
  133. package/src/theme/DocTagsListPage/index.tsx +33 -17
  134. package/src/theme/DocVersionRoot/index.tsx +51 -0
  135. package/src/theme/DocsRoot/index.tsx +22 -0
  136. package/src/theme/EditThisPage/index.tsx +3 -6
  137. package/src/theme/ErrorPageContent.tsx +3 -2
  138. package/src/theme/Icon/Copy/index.tsx +20 -0
  139. package/src/theme/Icon/Success/index.tsx +20 -0
  140. package/src/theme/Icon/WordWrap/index.tsx +20 -0
  141. package/src/theme/MDXComponents/Code.tsx +2 -39
  142. package/src/theme/MDXComponents/Details.tsx +1 -2
  143. package/src/theme/MDXComponents/Pre.tsx +5 -13
  144. package/src/theme/MDXComponents/index.tsx +3 -3
  145. package/src/theme/MDXContent/index.tsx +1 -0
  146. package/src/theme/MDXPage/index.tsx +16 -4
  147. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
  148. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
  149. package/src/theme/NotFound/Content/index.tsx +45 -0
  150. package/src/theme/NotFound/index.tsx +27 -0
  151. package/src/theme/SkipToContent/index.tsx +0 -1
  152. package/src/theme/TOCItems/Tree.tsx +3 -4
  153. package/src/theme/Tabs/index.tsx +4 -2
  154. package/src/theme/TagsListByLetter/index.tsx +4 -2
  155. package/src/theme/ThemedImage/index.tsx +8 -31
  156. package/src/theme/Unlisted/index.tsx +42 -0
  157. package/src/theme/prism-include-languages.ts +2 -1
  158. package/src/theme-classic.d.ts +154 -20
  159. package/lib/theme/DocPage/index.js +0 -67
  160. package/lib/theme/MDXComponents/Head.js +0 -23
  161. package/lib/theme/NotFound.js +0 -52
  162. package/src/theme/DocPage/index.tsx +0 -71
  163. package/src/theme/MDXComponents/Head.tsx +0 -29
  164. package/src/theme/NotFound.tsx +0 -54
  165. /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  166. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  167. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
  168. /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  169. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  170. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
@@ -14,25 +14,37 @@ import {
14
14
  import Layout from '@theme/Layout';
15
15
  import MDXContent from '@theme/MDXContent';
16
16
  import TOC from '@theme/TOC';
17
+ import Unlisted from '@theme/Unlisted';
17
18
  import styles from './styles.module.css';
18
19
  export default function MDXPage(props) {
19
20
  const {content: MDXPageContent} = props;
20
21
  const {
21
- metadata: {title, description, frontMatter},
22
+ metadata: {title, description, frontMatter, unlisted},
23
+ assets,
22
24
  } = MDXPageContent;
23
- const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
24
- frontMatter;
25
+ const {
26
+ keywords,
27
+ wrapperClassName,
28
+ hide_table_of_contents: hideTableOfContents,
29
+ } = frontMatter;
30
+ const image = assets.image ?? frontMatter.image;
25
31
  return (
26
32
  <HtmlClassNameProvider
27
33
  className={clsx(
28
34
  wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
29
35
  ThemeClassNames.page.mdxPage,
30
36
  )}>
31
- <PageMetadata title={title} description={description} />
32
37
  <Layout>
38
+ <PageMetadata
39
+ title={title}
40
+ description={description}
41
+ keywords={keywords}
42
+ image={image}
43
+ />
33
44
  <main className="container container--fluid margin-vert--lg">
34
45
  <div className={clsx('row', styles.mdxPageWrapper)}>
35
46
  <div className={clsx('col', !hideTableOfContents && 'col--8')}>
47
+ {unlisted && <Unlisted />}
36
48
  <article>
37
49
  <MDXContent>
38
50
  <MDXPageContent />
@@ -16,8 +16,9 @@ export default function DocNavbarItem({
16
16
  }) {
17
17
  const {activeDoc} = useActiveDocContext(docsPluginId);
18
18
  const doc = useLayoutDoc(docId, docsPluginId);
19
- // Draft items are not displayed in the navbar.
20
- if (doc === null) {
19
+ const pageActive = activeDoc?.path === doc?.path;
20
+ // Draft and unlisted items are not displayed in the navbar.
21
+ if (doc === null || (doc.unlisted && !pageActive)) {
21
22
  return null;
22
23
  }
23
24
  return (
@@ -25,7 +26,7 @@ export default function DocNavbarItem({
25
26
  exact
26
27
  {...props}
27
28
  isActive={() =>
28
- activeDoc?.path === doc.path ||
29
+ pageActive ||
29
30
  (!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
30
31
  }
31
32
  label={staticLabel ?? doc.id}
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/NavbarItem/LocaleDropdownNavbarItem';
9
- export default function LocaleDropdownNavbarItem({ mobile, dropdownItemsBefore, dropdownItemsAfter, ...props }: Props): JSX.Element;
9
+ export default function LocaleDropdownNavbarItem({ mobile, dropdownItemsBefore, dropdownItemsAfter, queryString, ...props }: Props): JSX.Element;
@@ -16,6 +16,7 @@ export default function LocaleDropdownNavbarItem({
16
16
  mobile,
17
17
  dropdownItemsBefore,
18
18
  dropdownItemsAfter,
19
+ queryString = '',
19
20
  ...props
20
21
  }) {
21
22
  const {
@@ -29,7 +30,7 @@ export default function LocaleDropdownNavbarItem({
29
30
  fullyQualified: false,
30
31
  })}`;
31
32
  // preserve ?search#hash suffix on locale switches
32
- const to = `${baseTo}${search}${hash}`;
33
+ const to = `${baseTo}${search}${hash}${queryString}`;
33
34
  return {
34
35
  label: localeConfigs[locale].label,
35
36
  lang: localeConfigs[locale].htmlLang,
@@ -0,0 +1,9 @@
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
+ /// <reference types="react" />
8
+ import type { Props } from '@theme/NotFound/Content';
9
+ export default function NotFoundContent({ className }: Props): JSX.Element;
@@ -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
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import Translate from '@docusaurus/Translate';
10
+ import Heading from '@theme/Heading';
11
+ export default function NotFoundContent({className}) {
12
+ return (
13
+ <main className={clsx('container margin-vert--xl', className)}>
14
+ <div className="row">
15
+ <div className="col col--6 col--offset-3">
16
+ <Heading as="h1" className="hero__title">
17
+ <Translate
18
+ id="theme.NotFound.title"
19
+ description="The title of the 404 page">
20
+ Page Not Found
21
+ </Translate>
22
+ </Heading>
23
+ <p>
24
+ <Translate
25
+ id="theme.NotFound.p1"
26
+ description="The first paragraph of the 404 page">
27
+ We could not find what you were looking for.
28
+ </Translate>
29
+ </p>
30
+ <p>
31
+ <Translate
32
+ id="theme.NotFound.p2"
33
+ description="The 2nd paragraph of the 404 page">
34
+ Please contact the owner of the site that linked you to the
35
+ original URL and let them know their link is broken.
36
+ </Translate>
37
+ </p>
38
+ </div>
39
+ </div>
40
+ </main>
41
+ );
42
+ }
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="react" />
8
- export default function NotFound(): JSX.Element;
8
+ export default function Index(): JSX.Element;
@@ -0,0 +1,25 @@
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
+ import React from 'react';
8
+ import {translate} from '@docusaurus/Translate';
9
+ import {PageMetadata} from '@docusaurus/theme-common';
10
+ import Layout from '@theme/Layout';
11
+ import NotFoundContent from '@theme/NotFound/Content';
12
+ export default function Index() {
13
+ const title = translate({
14
+ id: 'theme.NotFound.title',
15
+ message: 'Page Not Found',
16
+ });
17
+ return (
18
+ <>
19
+ <PageMetadata title={title} />
20
+ <Layout>
21
+ <NotFoundContent />
22
+ </Layout>
23
+ </>
24
+ );
25
+ }
@@ -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 Link from '@docusaurus/Link';
8
9
  // Recursive component rendering the toc tree
9
10
  function TOCItemTree({toc, className, linkClassName, isChild}) {
10
11
  if (!toc.length) {
@@ -14,12 +15,10 @@ function TOCItemTree({toc, className, linkClassName, isChild}) {
14
15
  <ul className={isChild ? undefined : className}>
15
16
  {toc.map((heading) => (
16
17
  <li key={heading.id}>
17
- {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
18
- <a
19
- href={`#${heading.id}`}
18
+ <Link
19
+ to={`#${heading.id}`}
20
20
  className={linkClassName ?? undefined}
21
21
  // Developer provided the HTML, so assume it's safe.
22
- // eslint-disable-next-line react/no-danger
23
22
  dangerouslySetInnerHTML={{__html: heading.value}}
24
23
  />
25
24
  <TOCItemTree
@@ -9,6 +9,7 @@ import clsx from 'clsx';
9
9
  import {
10
10
  useScrollPositionBlocker,
11
11
  useTabs,
12
+ sanitizeTabsChildren,
12
13
  } from '@docusaurus/theme-common/internal';
13
14
  import useIsBrowser from '@docusaurus/useIsBrowser';
14
15
  import styles from './styles.module.css';
@@ -119,7 +120,8 @@ export default function Tabs(props) {
119
120
  // Remount tabs after hydration
120
121
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
121
122
  key={String(isBrowser)}
122
- {...props}
123
- />
123
+ {...props}>
124
+ {sanitizeTabsChildren(props.children)}
125
+ </TabsComponent>
124
126
  );
125
127
  }
@@ -7,11 +7,14 @@
7
7
  import React from 'react';
8
8
  import {listTagsByLetters} from '@docusaurus/theme-common';
9
9
  import Tag from '@theme/Tag';
10
+ import Heading from '@theme/Heading';
10
11
  import styles from './styles.module.css';
11
12
  function TagLetterEntryItem({letterEntry}) {
12
13
  return (
13
14
  <article>
14
- <h2>{letterEntry.letter}</h2>
15
+ <Heading as="h2" id={letterEntry.letter}>
16
+ {letterEntry.letter}
17
+ </Heading>
15
18
  <ul className="padding--none">
16
19
  {letterEntry.tags.map((tag) => (
17
20
  <li key={tag.permalink} className={styles.tag}>
@@ -5,35 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
- import useIsBrowser from '@docusaurus/useIsBrowser';
10
- import {useColorMode} from '@docusaurus/theme-common';
11
- import styles from './styles.module.css';
8
+ import {ThemedComponent} from '@docusaurus/theme-common';
12
9
  export default function ThemedImage(props) {
13
- const isBrowser = useIsBrowser();
14
- const {colorMode} = useColorMode();
15
- const {sources, className, alt, ...propsRest} = props;
16
- const clientThemes = colorMode === 'dark' ? ['dark'] : ['light'];
17
- const renderedSourceNames = isBrowser
18
- ? clientThemes
19
- : // We need to render both images on the server to avoid flash
20
- // See https://github.com/facebook/docusaurus/pull/3730
21
- ['light', 'dark'];
10
+ const {sources, className: parentClassName, alt, ...propsRest} = props;
22
11
  return (
23
- <>
24
- {renderedSourceNames.map((sourceName) => (
12
+ <ThemedComponent className={parentClassName}>
13
+ {({theme, className}) => (
25
14
  <img
26
- key={sourceName}
27
- src={sources[sourceName]}
15
+ src={sources[theme]}
28
16
  alt={alt}
29
- className={clsx(
30
- styles.themedImage,
31
- styles[`themedImage--${sourceName}`],
32
- className,
33
- )}
17
+ className={className}
34
18
  {...propsRest}
35
19
  />
36
- ))}
37
- </>
20
+ )}
21
+ </ThemedComponent>
38
22
  );
39
23
  }
@@ -0,0 +1,9 @@
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
+ /// <reference types="react" />
8
+ import type { Props } from '@theme/Unlisted';
9
+ export default function Unlisted(props: Props): JSX.Element | null;
@@ -0,0 +1,38 @@
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
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import {
10
+ ThemeClassNames,
11
+ UnlistedBannerTitle,
12
+ UnlistedBannerMessage,
13
+ UnlistedMetadata,
14
+ } from '@docusaurus/theme-common';
15
+ import Admonition from '@theme/Admonition';
16
+ function UnlistedBanner({className}) {
17
+ return (
18
+ <Admonition
19
+ type="caution"
20
+ title={<UnlistedBannerTitle />}
21
+ className={clsx(className, ThemeClassNames.common.unlistedBanner)}>
22
+ <UnlistedBannerMessage />
23
+ </Admonition>
24
+ );
25
+ }
26
+ export default function Unlisted(props) {
27
+ return (
28
+ <>
29
+ {/*
30
+ Unlisted metadata declared here for simplicity.
31
+ Ensures we never forget to add the correct noindex metadata.
32
+ Also gives a central place for user to swizzle override default metadata.
33
+ */}
34
+ <UnlistedMetadata />
35
+ <UnlistedBanner {...props} />
36
+ </>
37
+ );
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "2.4.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,30 +20,30 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "2.4.0",
24
- "@docusaurus/mdx-loader": "2.4.0",
25
- "@docusaurus/module-type-aliases": "2.4.0",
26
- "@docusaurus/plugin-content-blog": "2.4.0",
27
- "@docusaurus/plugin-content-docs": "2.4.0",
28
- "@docusaurus/plugin-content-pages": "2.4.0",
29
- "@docusaurus/theme-common": "2.4.0",
30
- "@docusaurus/theme-translations": "2.4.0",
31
- "@docusaurus/types": "2.4.0",
32
- "@docusaurus/utils": "2.4.0",
33
- "@docusaurus/utils-common": "2.4.0",
34
- "@docusaurus/utils-validation": "2.4.0",
35
- "@mdx-js/react": "^1.6.22",
23
+ "@docusaurus/core": "3.0.0-alpha.0",
24
+ "@docusaurus/mdx-loader": "3.0.0-alpha.0",
25
+ "@docusaurus/module-type-aliases": "3.0.0-alpha.0",
26
+ "@docusaurus/plugin-content-blog": "3.0.0-alpha.0",
27
+ "@docusaurus/plugin-content-docs": "3.0.0-alpha.0",
28
+ "@docusaurus/plugin-content-pages": "3.0.0-alpha.0",
29
+ "@docusaurus/theme-common": "3.0.0-alpha.0",
30
+ "@docusaurus/theme-translations": "3.0.0-alpha.0",
31
+ "@docusaurus/types": "3.0.0-alpha.0",
32
+ "@docusaurus/utils": "3.0.0-alpha.0",
33
+ "@docusaurus/utils-common": "3.0.0-alpha.0",
34
+ "@docusaurus/utils-validation": "3.0.0-alpha.0",
35
+ "@mdx-js/react": "^2.1.5",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
38
38
  "infima": "0.2.0-alpha.43",
39
39
  "lodash": "^4.17.21",
40
40
  "nprogress": "^0.2.0",
41
- "postcss": "^8.4.14",
41
+ "postcss": "^8.4.21",
42
42
  "prism-react-renderer": "^1.3.5",
43
- "prismjs": "^1.28.0",
44
- "react-router-dom": "^5.3.3",
45
- "rtlcss": "^3.5.0",
46
- "tslib": "^2.4.0",
43
+ "prismjs": "^1.29.0",
44
+ "react-router-dom": "^5.3.4",
45
+ "rtlcss": "^4.0.0",
46
+ "tslib": "^2.5.0",
47
47
  "utility-types": "^3.10.0"
48
48
  },
49
49
  "devDependencies": {
@@ -51,16 +51,16 @@
51
51
  "@types/nprogress": "^0.2.0",
52
52
  "@types/prismjs": "^1.26.0",
53
53
  "@types/rtlcss": "^3.5.0",
54
- "fs-extra": "^10.1.0",
55
- "react-test-renderer": "^17.0.2",
54
+ "fs-extra": "^11.1.0",
55
+ "react-test-renderer": "^18.0.0",
56
56
  "utility-types": "^3.10.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "react": "^16.8.4 || ^17.0.0",
60
- "react-dom": "^16.8.4 || ^17.0.0"
59
+ "react": "^18.0.0",
60
+ "react-dom": "^18.0.0"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=16.14"
64
64
  },
65
- "gitHead": "898b85ef134cc43bf3b1209aad0ca8cdcfb214c5"
65
+ "gitHead": "7327f7ff880ed97ad7855744e59c9c55d467a950"
66
66
  }
@@ -12,6 +12,113 @@ import type {SwizzleConfig} from '@docusaurus/types';
12
12
  export default function getSwizzleConfig(): SwizzleConfig {
13
13
  return {
14
14
  components: {
15
+ 'Admonition/Icon': {
16
+ actions: {
17
+ eject: 'safe',
18
+ wrap: 'forbidden', // Can't wrap a folder
19
+ },
20
+ description: 'The folder containing all admonition icons',
21
+ },
22
+ 'Admonition/Icon/Caution': {
23
+ actions: {
24
+ eject: 'safe',
25
+ wrap: 'safe',
26
+ },
27
+ description: 'The admonition caution icon',
28
+ },
29
+ 'Admonition/Icon/Danger': {
30
+ actions: {
31
+ eject: 'safe',
32
+ wrap: 'safe',
33
+ },
34
+ description: 'The admonition danger icon',
35
+ },
36
+ 'Admonition/Icon/Info': {
37
+ actions: {
38
+ eject: 'safe',
39
+ wrap: 'safe',
40
+ },
41
+ description: 'The admonition info icon',
42
+ },
43
+ 'Admonition/Icon/Note': {
44
+ actions: {
45
+ eject: 'safe',
46
+ wrap: 'safe',
47
+ },
48
+ description: 'The admonition note icon',
49
+ },
50
+ 'Admonition/Icon/Tip': {
51
+ actions: {
52
+ eject: 'safe',
53
+ wrap: 'safe',
54
+ },
55
+ description: 'The admonition tip icon',
56
+ },
57
+ 'Admonition/Layout': {
58
+ actions: {
59
+ eject: 'safe',
60
+ wrap: 'safe',
61
+ },
62
+ description:
63
+ 'The standard admonition layout applied to all default admonition types',
64
+ },
65
+ 'Admonition/Type': {
66
+ actions: {
67
+ eject: 'safe',
68
+ wrap: 'forbidden',
69
+ },
70
+ description:
71
+ 'The folder containing all the admonition type components.',
72
+ },
73
+ 'Admonition/Type/Caution': {
74
+ actions: {
75
+ eject: 'safe',
76
+ wrap: 'safe',
77
+ },
78
+ description:
79
+ 'The component responsible for rendering a :::caution admonition type',
80
+ },
81
+ 'Admonition/Type/Danger': {
82
+ actions: {
83
+ eject: 'safe',
84
+ wrap: 'safe',
85
+ },
86
+ description:
87
+ 'The component responsible for rendering a :::danger admonition type',
88
+ },
89
+ 'Admonition/Type/Info': {
90
+ actions: {
91
+ eject: 'safe',
92
+ wrap: 'safe',
93
+ },
94
+ description:
95
+ 'The component responsible for rendering a :::info admonition type',
96
+ },
97
+ 'Admonition/Type/Note': {
98
+ actions: {
99
+ eject: 'safe',
100
+ wrap: 'safe',
101
+ },
102
+ description:
103
+ 'The component responsible for rendering a :::note admonition type',
104
+ },
105
+ 'Admonition/Type/Tip': {
106
+ actions: {
107
+ eject: 'safe',
108
+ wrap: 'safe',
109
+ },
110
+ description:
111
+ 'The component responsible for rendering a :::tip admonition type',
112
+ },
113
+ 'Admonition/Types': {
114
+ actions: {
115
+ eject: 'safe',
116
+ // TODO the swizzle CLI should provide a way to wrap such objects
117
+ wrap: 'forbidden',
118
+ },
119
+ description:
120
+ 'The object mapping admonition type to a React component.\nUse it to add custom admonition type components, or replace existing ones.\nCan be ejected or wrapped (only manually, see our documentation).',
121
+ },
15
122
  CodeBlock: {
16
123
  actions: {
17
124
  eject: 'safe',
@@ -205,14 +312,6 @@ export default function getSwizzleConfig(): SwizzleConfig {
205
312
  },
206
313
  description: 'The component used to render <details> tags in MDX',
207
314
  },
208
- 'MDXComponents/Head': {
209
- actions: {
210
- eject: 'forbidden',
211
- wrap: 'forbidden',
212
- },
213
- description:
214
- 'Technical component used to assign metadata (generally for SEO purpose) to the current MDX document',
215
- },
216
315
  'MDXComponents/Heading': {
217
316
  actions: {
218
317
  eject: 'safe',
package/src/index.ts CHANGED
@@ -26,7 +26,10 @@ const ContextReplacementPlugin = requireFromDocusaurusCore(
26
26
  // Need to be inlined to prevent dark mode FOUC
27
27
  // Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
28
28
  const ThemeStorageKey = 'theme';
29
+ // Support for ?docusaurus-theme=dark
29
30
  const ThemeQueryStringKey = 'docusaurus-theme';
31
+ // Support for ?docusaurus-data-mode=embed&docusaurus-data-myAttr=42
32
+ const DataQueryStringPrefixKey = 'docusaurus-data-';
30
33
 
31
34
  const noFlashColorMode = ({
32
35
  defaultMode,
@@ -42,19 +45,15 @@ const noFlashColorMode = ({
42
45
  }
43
46
 
44
47
  function getQueryStringTheme() {
45
- var theme = null;
46
48
  try {
47
- theme = new URLSearchParams(window.location.search).get('${ThemeQueryStringKey}')
49
+ return new URLSearchParams(window.location.search).get('${ThemeQueryStringKey}')
48
50
  } catch(e) {}
49
- return theme;
50
51
  }
51
52
 
52
53
  function getStoredTheme() {
53
- var theme = null;
54
54
  try {
55
- theme = localStorage.getItem('${ThemeStorageKey}');
55
+ return localStorage.getItem('${ThemeStorageKey}');
56
56
  } catch (err) {}
57
- return theme;
58
57
  }
59
58
 
60
59
  var initialTheme = getQueryStringTheme() || getStoredTheme();
@@ -77,6 +76,21 @@ const noFlashColorMode = ({
77
76
  }
78
77
  })();`;
79
78
 
79
+ /* language=js */
80
+ const DataAttributeQueryStringInlineJavaScript = `
81
+ (function() {
82
+ try {
83
+ const entries = new URLSearchParams(window.location.search).entries();
84
+ for (var [searchKey, value] of entries) {
85
+ if (searchKey.startsWith('${DataQueryStringPrefixKey}')) {
86
+ var key = searchKey.replace('${DataQueryStringPrefixKey}',"data-")
87
+ document.documentElement.setAttribute(key, value);
88
+ }
89
+ }
90
+ } catch(e) {}
91
+ })();
92
+ `;
93
+
80
94
  // Duplicated constant. Unfortunately we can't import it from theme-common, as
81
95
  // we need to support older nodejs versions without ESM support
82
96
  // TODO: import from theme-common once we only support Node.js with ESM support
@@ -205,6 +219,7 @@ export default function themeClassic(
205
219
  tagName: 'script',
206
220
  innerHTML: `
207
221
  ${noFlashColorMode(colorMode)}
222
+ ${DataAttributeQueryStringInlineJavaScript}
208
223
  ${announcementBar ? AnnouncementBarInlineJavaScript : ''}
209
224
  `,
210
225
  },
package/src/nprogress.ts CHANGED
@@ -6,9 +6,10 @@
6
6
  */
7
7
 
8
8
  import nprogress from 'nprogress';
9
- import './nprogress.css';
10
9
  import type {ClientModule} from '@docusaurus/types';
11
10
 
11
+ import './nprogress.css';
12
+
12
13
  nprogress.configure({showSpinner: false});
13
14
 
14
15
  const delay = 200;
package/src/options.ts CHANGED
@@ -200,6 +200,7 @@ const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
200
200
  type: Joi.string().equal('localeDropdown').required(),
201
201
  dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
202
202
  dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
203
+ queryString: Joi.string(),
203
204
  });
204
205
 
205
206
  const SearchItemSchema = Joi.object({
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import type {Props} from '@theme/Admonition/Icon/Caution';
10
+
11
+ export default function AdmonitionIconCaution(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 16 16" {...props}>
14
+ <path
15
+ fillRule="evenodd"
16
+ d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import type {Props} from '@theme/Admonition/Icon/Danger';
10
+
11
+ export default function AdmonitionIconDanger(props: Props): JSX.Element {
12
+ return (
13
+ <svg viewBox="0 0 12 16" {...props}>
14
+ <path
15
+ fillRule="evenodd"
16
+ d="M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"
17
+ />
18
+ </svg>
19
+ );
20
+ }