@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
@@ -17,6 +17,7 @@ import BlogLayout from '@theme/BlogLayout';
17
17
  import TagsListByLetter from '@theme/TagsListByLetter';
18
18
  import type {Props} from '@theme/BlogTagsListPage';
19
19
  import SearchMetadata from '@theme/SearchMetadata';
20
+ import Heading from '@theme/Heading';
20
21
 
21
22
  export default function BlogTagsListPage({tags, sidebar}: Props): JSX.Element {
22
23
  const title = translateTagsPageTitle();
@@ -29,7 +30,7 @@ export default function BlogTagsListPage({tags, sidebar}: Props): JSX.Element {
29
30
  <PageMetadata title={title} />
30
31
  <SearchMetadata tag="blog_tags_list" />
31
32
  <BlogLayout sidebar={sidebar}>
32
- <h1>{title}</h1>
33
+ <Heading as="h1">{title}</Heading>
33
34
  <TagsListByLetter tags={tags} />
34
35
  </BlogLayout>
35
36
  </HtmlClassNameProvider>
@@ -20,6 +20,8 @@ import BlogListPaginator from '@theme/BlogListPaginator';
20
20
  import SearchMetadata from '@theme/SearchMetadata';
21
21
  import type {Props} from '@theme/BlogTagsPostsPage';
22
22
  import BlogPostItems from '@theme/BlogPostItems';
23
+ import Unlisted from '@theme/Unlisted';
24
+ import Heading from '@theme/Heading';
23
25
 
24
26
  // Very simple pluralization: probably good enough for now
25
27
  function useBlogPostsPlural() {
@@ -70,9 +72,9 @@ function BlogTagsPostsPageContent({
70
72
  const title = useBlogTagsPostsPageTitle(tag);
71
73
  return (
72
74
  <BlogLayout sidebar={sidebar}>
75
+ {tag.unlisted && <Unlisted />}
73
76
  <header className="margin-bottom--xl">
74
- <h1>{title}</h1>
75
-
77
+ <Heading as="h1">{title}</Heading>
76
78
  <Link href={tag.allTagsPath}>
77
79
  <Translate
78
80
  id="theme.tags.tagsPageLink"
@@ -11,6 +11,8 @@ import clsx from 'clsx';
11
11
  import copy from 'copy-text-to-clipboard';
12
12
  import {translate} from '@docusaurus/Translate';
13
13
  import type {Props} from '@theme/CodeBlock/CopyButton';
14
+ import IconCopy from '@theme/Icon/Copy';
15
+ import IconSuccess from '@theme/Icon/Success';
14
16
 
15
17
  import styles from './styles.module.css';
16
18
 
@@ -56,12 +58,8 @@ export default function CopyButton({code, className}: Props): JSX.Element {
56
58
  )}
57
59
  onClick={handleCopyCode}>
58
60
  <span className={styles.copyButtonIcons} aria-hidden="true">
59
- <svg className={styles.copyButtonIcon} viewBox="0 0 24 24">
60
- <path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />
61
- </svg>
62
- <svg className={styles.copyButtonSuccessIcon} viewBox="0 0 24 24">
63
- <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
64
- </svg>
61
+ <IconCopy className={styles.copyButtonIcon} />
62
+ <IconSuccess className={styles.copyButtonSuccessIcon} />
65
63
  </span>
66
64
  </button>
67
65
  );
@@ -9,6 +9,7 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {translate} from '@docusaurus/Translate';
11
11
  import type {Props} from '@theme/CodeBlock/WordWrapButton';
12
+ import IconWordWrap from '@theme/Icon/WordWrap';
12
13
 
13
14
  import styles from './styles.module.css';
14
15
 
@@ -35,15 +36,7 @@ export default function WordWrapButton({
35
36
  )}
36
37
  aria-label={title}
37
38
  title={title}>
38
- <svg
39
- className={styles.wordWrapButtonIcon}
40
- viewBox="0 0 24 24"
41
- aria-hidden="true">
42
- <path
43
- fill="currentColor"
44
- d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"
45
- />
46
- </svg>
39
+ <IconWordWrap className={styles.wordWrapButtonIcon} aria-hidden="true" />
47
40
  </button>
48
41
  );
49
42
  }
@@ -104,13 +104,17 @@ export default function DocBreadcrumbs(): JSX.Element | null {
104
104
  {homePageRoute && <HomeBreadcrumbItem />}
105
105
  {breadcrumbs.map((item, idx) => {
106
106
  const isLast = idx === breadcrumbs.length - 1;
107
+ const href =
108
+ item.type === 'category' && item.linkUnlisted
109
+ ? undefined
110
+ : item.href;
107
111
  return (
108
112
  <BreadcrumbsItem
109
113
  key={idx}
110
114
  active={isLast}
111
115
  index={idx}
112
- addMicrodata={!!item.href}>
113
- <BreadcrumbsItemLink href={item.href} isLast={isLast}>
116
+ addMicrodata={!!href}>
117
+ <BreadcrumbsItemLink href={href} isLast={isLast}>
114
118
  {item.label}
115
119
  </BreadcrumbsItemLink>
116
120
  </BreadcrumbsItem>
@@ -9,19 +9,21 @@ import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Link from '@docusaurus/Link';
11
11
  import {
12
- findFirstCategoryLink,
12
+ findFirstSidebarItemLink,
13
13
  useDocById,
14
14
  } from '@docusaurus/theme-common/internal';
15
15
  import isInternalUrl from '@docusaurus/isInternalUrl';
16
16
  import {translate} from '@docusaurus/Translate';
17
- import type {Props} from '@theme/DocCard';
18
17
 
19
- import styles from './styles.module.css';
18
+ import type {Props} from '@theme/DocCard';
19
+ import Heading from '@theme/Heading';
20
20
  import type {
21
21
  PropSidebarItemCategory,
22
22
  PropSidebarItemLink,
23
23
  } from '@docusaurus/plugin-content-docs';
24
24
 
25
+ import styles from './styles.module.css';
26
+
25
27
  function CardContainer({
26
28
  href,
27
29
  children,
@@ -51,9 +53,12 @@ function CardLayout({
51
53
  }): JSX.Element {
52
54
  return (
53
55
  <CardContainer href={href}>
54
- <h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
56
+ <Heading
57
+ as="h2"
58
+ className={clsx('text--truncate', styles.cardTitle)}
59
+ title={title}>
55
60
  {icon} {title}
56
- </h2>
61
+ </Heading>
57
62
  {description && (
58
63
  <p
59
64
  className={clsx('text--truncate', styles.cardDescription)}
@@ -70,7 +75,7 @@ function CardCategory({
70
75
  }: {
71
76
  item: PropSidebarItemCategory;
72
77
  }): JSX.Element | null {
73
- const href = findFirstCategoryLink(item);
78
+ const href = findFirstSidebarItemLink(item);
74
79
 
75
80
  // Unexpected: categories that don't have a link have been filtered upfront
76
81
  if (!href) {
@@ -17,6 +17,7 @@ import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
17
17
  import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
18
18
  import DocItemContent from '@theme/DocItem/Content';
19
19
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
20
+ import Unlisted from '@theme/Unlisted';
20
21
  import type {Props} from '@theme/DocItem/Layout';
21
22
 
22
23
  import styles from './styles.module.css';
@@ -47,9 +48,13 @@ function useDocTOC() {
47
48
 
48
49
  export default function DocItemLayout({children}: Props): JSX.Element {
49
50
  const docTOC = useDocTOC();
51
+ const {
52
+ metadata: {unlisted},
53
+ } = useDoc();
50
54
  return (
51
55
  <div className="row">
52
56
  <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
57
+ {unlisted && <Unlisted />}
53
58
  <DocVersionBanner />
54
59
  <div className={styles.docItemContainer}>
55
60
  <article>
@@ -17,7 +17,7 @@ export default function DocPaginator(props: Props): JSX.Element {
17
17
  className="pagination-nav docusaurus-mt-lg"
18
18
  aria-label={translate({
19
19
  id: 'theme.docs.paginator.navAriaLabel',
20
- message: 'Docs pages navigation',
20
+ message: 'Docs pages',
21
21
  description: 'The ARIA label for the docs pagination',
22
22
  })}>
23
23
  {previous && (
@@ -8,11 +8,11 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
11
- import type {Props} from '@theme/DocPage/Layout/Main';
11
+ import type {Props} from '@theme/DocRoot/Layout/Main';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- export default function DocPageLayoutMain({
15
+ export default function DocRootLayoutMain({
16
16
  hiddenSidebarContainer,
17
17
  children,
18
18
  }: Props): JSX.Element {
@@ -8,11 +8,11 @@
8
8
  import React from 'react';
9
9
  import {translate} from '@docusaurus/Translate';
10
10
  import IconArrow from '@theme/Icon/Arrow';
11
- import type {Props} from '@theme/DocPage/Layout/Sidebar/ExpandButton';
11
+ import type {Props} from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- export default function DocPageLayoutSidebarExpandButton({
15
+ export default function DocRootLayoutSidebarExpandButton({
16
16
  toggleSidebar,
17
17
  }: Props): JSX.Element {
18
18
  return (
@@ -7,12 +7,12 @@
7
7
 
8
8
  import React, {type ReactNode, useState, useCallback} from 'react';
9
9
  import clsx from 'clsx';
10
- import {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
11
11
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
12
12
  import {useLocation} from '@docusaurus/router';
13
13
  import DocSidebar from '@theme/DocSidebar';
14
- import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
15
- import type {Props} from '@theme/DocPage/Layout/Sidebar';
14
+ import ExpandButton from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
15
+ import type {Props} from '@theme/DocRoot/Layout/Sidebar';
16
16
 
17
17
  import styles from './styles.module.css';
18
18
 
@@ -28,7 +28,7 @@ function ResetOnSidebarChange({children}: {children: ReactNode}) {
28
28
  );
29
29
  }
30
30
 
31
- export default function DocPageLayoutSidebar({
31
+ export default function DocRootLayoutSidebar({
32
32
  sidebar,
33
33
  hiddenSidebarContainer,
34
34
  setHiddenSidebarContainer,
@@ -40,6 +40,11 @@ export default function DocPageLayoutSidebar({
40
40
  if (hiddenSidebar) {
41
41
  setHiddenSidebar(false);
42
42
  }
43
+ // onTransitionEnd won't fire when sidebar animation is disabled
44
+ // fixes https://github.com/facebook/docusaurus/issues/8918
45
+ if (!hiddenSidebar && prefersReducedMotion()) {
46
+ setHiddenSidebar(true);
47
+ }
43
48
  setHiddenSidebarContainer((value) => !value);
44
49
  }, [setHiddenSidebarContainer, hiddenSidebar]);
45
50
 
@@ -7,32 +7,31 @@
7
7
 
8
8
  import React, {useState} from 'react';
9
9
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
10
- import Layout from '@theme/Layout';
11
10
  import BackToTopButton from '@theme/BackToTopButton';
12
- import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
13
- import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
14
- import type {Props} from '@theme/DocPage/Layout';
11
+ import DocRootLayoutSidebar from '@theme/DocRoot/Layout/Sidebar';
12
+ import DocRootLayoutMain from '@theme/DocRoot/Layout/Main';
13
+ import type {Props} from '@theme/DocRoot/Layout';
15
14
 
16
15
  import styles from './styles.module.css';
17
16
 
18
- export default function DocPageLayout({children}: Props): JSX.Element {
17
+ export default function DocRootLayout({children}: Props): JSX.Element {
19
18
  const sidebar = useDocsSidebar();
20
19
  const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
21
20
  return (
22
- <Layout wrapperClassName={styles.docsWrapper}>
21
+ <div className={styles.docsWrapper}>
23
22
  <BackToTopButton />
24
- <div className={styles.docPage}>
23
+ <div className={styles.docRoot}>
25
24
  {sidebar && (
26
- <DocPageLayoutSidebar
25
+ <DocRootLayoutSidebar
27
26
  sidebar={sidebar.items}
28
27
  hiddenSidebarContainer={hiddenSidebarContainer}
29
28
  setHiddenSidebarContainer={setHiddenSidebarContainer}
30
29
  />
31
30
  )}
32
- <DocPageLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
31
+ <DocRootLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
33
32
  {children}
34
- </DocPageLayoutMain>
33
+ </DocRootLayoutMain>
35
34
  </div>
36
- </Layout>
35
+ </div>
37
36
  );
38
37
  }
@@ -5,10 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docPage {
8
+ .docRoot {
9
9
  display: flex;
10
10
  width: 100%;
11
- flex: 1 0;
12
11
  }
13
12
 
14
13
  .docsWrapper {
@@ -0,0 +1,34 @@
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 {HtmlClassNameProvider, ThemeClassNames} from '@docusaurus/theme-common';
11
+ import {
12
+ DocsSidebarProvider,
13
+ useDocRootMetadata,
14
+ } from '@docusaurus/theme-common/internal';
15
+ import DocRootLayout from '@theme/DocRoot/Layout';
16
+ import NotFoundContent from '@theme/NotFound/Content';
17
+ import type {Props} from '@theme/DocRoot';
18
+
19
+ export default function DocRoot(props: Props): JSX.Element {
20
+ const currentDocRouteMetadata = useDocRootMetadata(props);
21
+ if (!currentDocRouteMetadata) {
22
+ // We only render the not found content to avoid a double layout
23
+ // see https://github.com/facebook/docusaurus/pull/7966#pullrequestreview-1077276692
24
+ return <NotFoundContent />;
25
+ }
26
+ const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
27
+ return (
28
+ <HtmlClassNameProvider className={clsx(ThemeClassNames.page.docsDocPage)}>
29
+ <DocsSidebarProvider name={sidebarName} items={sidebarItems}>
30
+ <DocRootLayout>{docElement}</DocRootLayout>
31
+ </DocsSidebarProvider>
32
+ </HtmlClassNameProvider>
33
+ );
34
+ }
@@ -16,7 +16,7 @@ import {
16
16
  } from '@docusaurus/theme-common';
17
17
  import {
18
18
  isActiveSidebarItem,
19
- findFirstCategoryLink,
19
+ findFirstSidebarItemLink,
20
20
  useDocSidebarItemsExpandedState,
21
21
  isSamePath,
22
22
  } from '@docusaurus/theme-common/internal';
@@ -59,7 +59,7 @@ function useCategoryHrefWithSSRFallback(
59
59
  ): string | undefined {
60
60
  const isBrowser = useIsBrowser();
61
61
  return useMemo(() => {
62
- if (item.href) {
62
+ if (item.href && !item.linkUnlisted) {
63
63
  return item.href;
64
64
  }
65
65
  // In these cases, it's not necessary to render a fallback
@@ -67,7 +67,7 @@ function useCategoryHrefWithSSRFallback(
67
67
  if (isBrowser || !item.collapsible) {
68
68
  return undefined;
69
69
  }
70
- return findFirstCategoryLink(item);
70
+ return findFirstSidebarItemLink(item);
71
71
  }, [item, isBrowser]);
72
72
  }
73
73
 
@@ -6,17 +6,19 @@
6
6
  */
7
7
 
8
8
  import React, {memo} from 'react';
9
- import {DocSidebarItemsExpandedStateProvider} from '@docusaurus/theme-common/internal';
9
+ import {
10
+ DocSidebarItemsExpandedStateProvider,
11
+ useVisibleSidebarItems,
12
+ } from '@docusaurus/theme-common/internal';
10
13
  import DocSidebarItem from '@theme/DocSidebarItem';
11
14
 
12
15
  import type {Props} from '@theme/DocSidebarItems';
13
16
 
14
- // TODO this item should probably not receive the "activePath" props
15
- // TODO this triggers whole sidebar re-renders on navigation
16
17
  function DocSidebarItems({items, ...props}: Props): JSX.Element {
18
+ const visibleItems = useVisibleSidebarItems(items, props.activePath);
17
19
  return (
18
20
  <DocSidebarItemsExpandedStateProvider>
19
- {items.map((item, index) => (
21
+ {visibleItems.map((item, index) => (
20
22
  <DocSidebarItem key={index} item={item} index={index} {...props} />
21
23
  ))}
22
24
  </DocSidebarItemsExpandedStateProvider>
@@ -15,9 +15,10 @@ import {
15
15
  usePluralForm,
16
16
  } from '@docusaurus/theme-common';
17
17
  import Translate, {translate} from '@docusaurus/Translate';
18
- import Layout from '@theme/Layout';
19
18
  import SearchMetadata from '@theme/SearchMetadata';
20
19
  import type {Props} from '@theme/DocTagDocListPage';
20
+ import Unlisted from '@theme/Unlisted';
21
+ import Heading from '@theme/Heading';
21
22
 
22
23
  // Very simple pluralization: probably good enough for now
23
24
  function useNDocsTaggedPlural() {
@@ -37,59 +38,79 @@ function useNDocsTaggedPlural() {
37
38
  );
38
39
  }
39
40
 
41
+ function usePageTitle(props: Props): string {
42
+ const nDocsTaggedPlural = useNDocsTaggedPlural();
43
+ return translate(
44
+ {
45
+ id: 'theme.docs.tagDocListPageTitle',
46
+ description: 'The title of the page for a docs tag',
47
+ message: '{nDocsTagged} with "{tagName}"',
48
+ },
49
+ {nDocsTagged: nDocsTaggedPlural(props.tag.count), tagName: props.tag.label},
50
+ );
51
+ }
52
+
40
53
  function DocItem({doc}: {doc: Props['tag']['items'][number]}): JSX.Element {
41
54
  return (
42
55
  <article className="margin-vert--lg">
43
56
  <Link to={doc.permalink}>
44
- <h2>{doc.title}</h2>
57
+ <Heading as="h2">{doc.title}</Heading>
45
58
  </Link>
46
59
  {doc.description && <p>{doc.description}</p>}
47
60
  </article>
48
61
  );
49
62
  }
50
63
 
51
- export default function DocTagDocListPage({tag}: Props): JSX.Element {
52
- const nDocsTaggedPlural = useNDocsTaggedPlural();
53
- const title = translate(
54
- {
55
- id: 'theme.docs.tagDocListPageTitle',
56
- description: 'The title of the page for a docs tag',
57
- message: '{nDocsTagged} with "{tagName}"',
58
- },
59
- {nDocsTagged: nDocsTaggedPlural(tag.count), tagName: tag.label},
64
+ function DocTagDocListPageMetadata({
65
+ title,
66
+ }: Props & {title: string}): JSX.Element {
67
+ return (
68
+ <>
69
+ <PageMetadata title={title} />
70
+ <SearchMetadata tag="doc_tag_doc_list" />
71
+ </>
60
72
  );
73
+ }
61
74
 
75
+ function DocTagDocListPageContent({
76
+ tag,
77
+ title,
78
+ }: Props & {title: string}): JSX.Element {
62
79
  return (
63
80
  <HtmlClassNameProvider
64
- className={clsx(
65
- ThemeClassNames.wrapper.docsPages,
66
- ThemeClassNames.page.docsTagDocListPage,
67
- )}>
68
- <PageMetadata title={title} />
69
- <SearchMetadata tag="doc_tag_doc_list" />
70
- <Layout>
71
- <div className="container margin-vert--lg">
72
- <div className="row">
73
- <main className="col col--8 col--offset-2">
74
- <header className="margin-bottom--xl">
75
- <h1>{title}</h1>
76
- <Link href={tag.allTagsPath}>
77
- <Translate
78
- id="theme.tags.tagsPageLink"
79
- description="The label of the link targeting the tag list page">
80
- View All Tags
81
- </Translate>
82
- </Link>
83
- </header>
84
- <section className="margin-vert--lg">
85
- {tag.items.map((doc) => (
86
- <DocItem key={doc.id} doc={doc} />
87
- ))}
88
- </section>
89
- </main>
90
- </div>
81
+ className={clsx(ThemeClassNames.page.docsTagDocListPage)}>
82
+ <div className="container margin-vert--lg">
83
+ <div className="row">
84
+ <main className="col col--8 col--offset-2">
85
+ {tag.unlisted && <Unlisted />}
86
+ <header className="margin-bottom--xl">
87
+ <Heading as="h1">{title}</Heading>
88
+ <Link href={tag.allTagsPath}>
89
+ <Translate
90
+ id="theme.tags.tagsPageLink"
91
+ description="The label of the link targeting the tag list page">
92
+ View All Tags
93
+ </Translate>
94
+ </Link>
95
+ </header>
96
+ <section className="margin-vert--lg">
97
+ {tag.items.map((doc) => (
98
+ <DocItem key={doc.id} doc={doc} />
99
+ ))}
100
+ </section>
101
+ </main>
91
102
  </div>
92
- </Layout>
103
+ </div>
93
104
  </HtmlClassNameProvider>
94
105
  );
95
106
  }
107
+
108
+ export default function DocTagDocListPage(props: Props): JSX.Element {
109
+ const title = usePageTitle(props);
110
+ return (
111
+ <>
112
+ <DocTagDocListPageMetadata {...props} title={title} />
113
+ <DocTagDocListPageContent {...props} title={title} />
114
+ </>
115
+ );
116
+ }
@@ -13,31 +13,47 @@ import {
13
13
  ThemeClassNames,
14
14
  translateTagsPageTitle,
15
15
  } from '@docusaurus/theme-common';
16
- import Layout from '@theme/Layout';
17
16
  import TagsListByLetter from '@theme/TagsListByLetter';
18
17
  import SearchMetadata from '@theme/SearchMetadata';
19
18
  import type {Props} from '@theme/DocTagsListPage';
19
+ import Heading from '@theme/Heading';
20
20
 
21
- export default function DocTagsListPage({tags}: Props): JSX.Element {
22
- const title = translateTagsPageTitle();
21
+ function DocTagsListPageMetadata({
22
+ title,
23
+ }: Props & {title: string}): JSX.Element {
23
24
  return (
24
- <HtmlClassNameProvider
25
- className={clsx(
26
- ThemeClassNames.wrapper.docsPages,
27
- ThemeClassNames.page.docsTagsListPage,
28
- )}>
25
+ <>
29
26
  <PageMetadata title={title} />
30
27
  <SearchMetadata tag="doc_tags_list" />
31
- <Layout>
32
- <div className="container margin-vert--lg">
33
- <div className="row">
34
- <main className="col col--8 col--offset-2">
35
- <h1>{title}</h1>
36
- <TagsListByLetter tags={tags} />
37
- </main>
38
- </div>
28
+ </>
29
+ );
30
+ }
31
+
32
+ function DocTagsListPageContent({
33
+ tags,
34
+ title,
35
+ }: Props & {title: string}): JSX.Element {
36
+ return (
37
+ <HtmlClassNameProvider
38
+ className={clsx(ThemeClassNames.page.docsTagsListPage)}>
39
+ <div className="container margin-vert--lg">
40
+ <div className="row">
41
+ <main className="col col--8 col--offset-2">
42
+ <Heading as="h1">{title}</Heading>
43
+ <TagsListByLetter tags={tags} />
44
+ </main>
39
45
  </div>
40
- </Layout>
46
+ </div>
41
47
  </HtmlClassNameProvider>
42
48
  );
43
49
  }
50
+
51
+ export default function DocTagsListPage(props: Props): JSX.Element {
52
+ const title = translateTagsPageTitle();
53
+ return (
54
+ <>
55
+ <DocTagsListPageMetadata {...props} title={title} />
56
+ <DocTagsListPageContent {...props} title={title} />
57
+ </>
58
+ );
59
+ }
@@ -0,0 +1,51 @@
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 {HtmlClassNameProvider, PageMetadata} from '@docusaurus/theme-common';
10
+ import {
11
+ docVersionSearchTag,
12
+ DocsVersionProvider,
13
+ } from '@docusaurus/theme-common/internal';
14
+ import renderRoutes from '@docusaurus/renderRoutes';
15
+ import SearchMetadata from '@theme/SearchMetadata';
16
+
17
+ import type {Props} from '@theme/DocVersionRoot';
18
+
19
+ function DocVersionRootMetadata(props: Props): JSX.Element {
20
+ const {version} = props;
21
+ return (
22
+ <>
23
+ <SearchMetadata
24
+ version={version.version}
25
+ tag={docVersionSearchTag(version.pluginId, version.version)}
26
+ />
27
+ <PageMetadata>
28
+ {version.noIndex && <meta name="robots" content="noindex, nofollow" />}
29
+ </PageMetadata>
30
+ </>
31
+ );
32
+ }
33
+
34
+ function DocVersionRootContent(props: Props): JSX.Element {
35
+ const {version, route} = props;
36
+ return (
37
+ <HtmlClassNameProvider className={version.className}>
38
+ <DocsVersionProvider version={version}>
39
+ {renderRoutes(route.routes!)}
40
+ </DocsVersionProvider>
41
+ </HtmlClassNameProvider>
42
+ );
43
+ }
44
+ export default function DocVersionRoot(props: Props): JSX.Element {
45
+ return (
46
+ <>
47
+ <DocVersionRootMetadata {...props} />
48
+ <DocVersionRootContent {...props} />
49
+ </>
50
+ );
51
+ }