@docusaurus/theme-classic 2.0.0-beta.17 → 2.0.0-beta.18

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 (184) hide show
  1. package/lib/getSwizzleConfig.js +113 -2
  2. package/lib/index.js +7 -12
  3. package/lib/theme-classic.d.ts +286 -60
  4. package/lib/translations.js +12 -2
  5. package/lib/validateThemeConfig.js +1 -1
  6. package/lib-next/theme/BackToTopButton/index.js +1 -3
  7. package/lib-next/theme/BlogArchivePage/index.js +14 -10
  8. package/lib-next/theme/BlogListPage/index.js +34 -13
  9. package/lib-next/theme/BlogPostItem/index.js +6 -6
  10. package/lib-next/theme/BlogPostPage/index.js +56 -45
  11. package/lib-next/theme/BlogTagsListPage/index.js +16 -12
  12. package/lib-next/theme/BlogTagsPostsPage/index.js +40 -33
  13. package/lib-next/theme/CodeBlock/CopyButton/index.js +60 -0
  14. package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +66 -0
  15. package/lib-next/theme/CodeBlock/index.js +4 -36
  16. package/lib-next/theme/CodeBlock/styles.module.css +2 -22
  17. package/lib-next/theme/ColorModeToggle/index.js +36 -57
  18. package/lib-next/theme/ColorModeToggle/styles.module.css +8 -24
  19. package/lib-next/theme/DocBreadcrumbs/index.js +28 -11
  20. package/lib-next/theme/DocBreadcrumbs/styles.module.css +2 -17
  21. package/lib-next/theme/DocCard/index.js +17 -15
  22. package/lib-next/theme/DocCard/styles.module.css +8 -17
  23. package/lib-next/theme/DocCardList/index.js +15 -3
  24. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +27 -6
  25. package/lib-next/theme/DocItem/index.js +84 -66
  26. package/lib-next/theme/DocPage/index.js +88 -89
  27. package/lib-next/theme/DocPage/styles.module.css +0 -4
  28. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
  29. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  30. package/lib-next/theme/DocSidebar/Desktop/Content/index.js +46 -0
  31. package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  32. package/lib-next/theme/DocSidebar/Desktop/index.js +34 -0
  33. package/lib-next/theme/DocSidebar/Desktop/styles.module.css +50 -0
  34. package/lib-next/theme/DocSidebar/Mobile/index.js +49 -0
  35. package/lib-next/theme/DocSidebar/index.js +6 -113
  36. package/lib-next/theme/DocSidebarItem/index.js +14 -13
  37. package/lib-next/theme/DocSidebarItem/styles.module.css +4 -0
  38. package/lib-next/theme/DocTagDocListPage/index.js +38 -31
  39. package/lib-next/theme/DocTagsListPage/index.js +21 -16
  40. package/lib-next/theme/Footer/Copyright/index.js +18 -0
  41. package/lib-next/theme/Footer/Layout/index.js +26 -0
  42. package/lib-next/theme/Footer/LinkItem/index.js +33 -0
  43. package/lib-next/theme/Footer/Links/MultiColumn/index.js +47 -0
  44. package/lib-next/theme/Footer/Links/Simple/index.js +41 -0
  45. package/lib-next/theme/Footer/Links/index.js +17 -0
  46. package/lib-next/theme/Footer/Logo/index.js +38 -0
  47. package/lib-next/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  48. package/lib-next/theme/Footer/index.js +11 -163
  49. package/lib-next/theme/Heading/index.js +6 -4
  50. package/lib-next/theme/IconExternalLink/styles.module.css +0 -2
  51. package/lib-next/theme/Layout/index.js +15 -10
  52. package/lib-next/theme/LayoutProviders/index.js +5 -4
  53. package/lib-next/theme/MDXComponents/A.js +11 -0
  54. package/lib-next/theme/MDXComponents/Code.js +28 -0
  55. package/lib-next/theme/MDXComponents/Details.js +20 -0
  56. package/lib-next/theme/MDXComponents/Head.js +26 -0
  57. package/lib-next/theme/MDXComponents/Heading.js +11 -0
  58. package/lib-next/theme/MDXComponents/Img.js +24 -0
  59. package/lib-next/theme/MDXComponents/Img.module.css +10 -0
  60. package/lib-next/theme/MDXComponents/Pre.js +18 -0
  61. package/lib-next/theme/MDXComponents/Ul.js +23 -0
  62. package/{src/theme/MDXComponents/styles.css → lib-next/theme/MDXComponents/Ul.module.css} +1 -5
  63. package/lib-next/theme/MDXComponents/index.js +22 -71
  64. package/lib-next/theme/MDXContent/index.js +12 -0
  65. package/lib-next/theme/MDXPage/index.js +33 -28
  66. package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
  67. package/lib-next/theme/Navbar/Content/index.js +70 -0
  68. package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
  69. package/lib-next/theme/Navbar/Layout/index.js +54 -0
  70. package/{src/theme/Navbar → lib-next/theme/Navbar/Layout}/styles.module.css +0 -13
  71. package/lib-next/theme/Navbar/Logo/index.js +17 -0
  72. package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
  73. package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
  74. package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
  75. package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
  76. package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
  77. package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
  78. package/lib-next/theme/Navbar/index.js +6 -271
  79. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +2 -6
  80. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +10 -2
  81. package/lib-next/theme/NavbarItem/NavbarNavLink.js +8 -12
  82. package/lib-next/theme/NotFound.js +38 -33
  83. package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +11 -26
  84. package/lib-next/theme/TOCCollapsible/index.js +1 -3
  85. package/lib-next/theme/Tabs/__tests__/index.test.js +5 -5
  86. package/lib-next/theme/Tabs/index.js +2 -2
  87. package/lib-next/theme/Tag/index.js +4 -4
  88. package/lib-next/theme/ThemedImage/index.js +3 -3
  89. package/package.json +17 -17
  90. package/src/getSwizzleConfig.ts +122 -1
  91. package/src/index.ts +10 -12
  92. package/src/theme/BackToTopButton/index.tsx +1 -3
  93. package/src/theme/BlogArchivePage/index.tsx +18 -17
  94. package/src/theme/BlogLayout/index.tsx +1 -1
  95. package/src/theme/BlogListPage/index.tsx +32 -13
  96. package/src/theme/BlogPostItem/index.tsx +6 -6
  97. package/src/theme/BlogPostPage/index.tsx +55 -48
  98. package/src/theme/BlogTagsListPage/index.tsx +16 -12
  99. package/src/theme/BlogTagsPostsPage/index.tsx +39 -32
  100. package/src/theme/CodeBlock/CopyButton/index.tsx +66 -0
  101. package/src/theme/CodeBlock/CopyButton/styles.module.css +66 -0
  102. package/src/theme/CodeBlock/index.tsx +6 -38
  103. package/src/theme/CodeBlock/styles.module.css +2 -22
  104. package/src/theme/ColorModeToggle/index.tsx +36 -61
  105. package/src/theme/ColorModeToggle/styles.module.css +8 -24
  106. package/src/theme/DocBreadcrumbs/index.tsx +29 -10
  107. package/src/theme/DocBreadcrumbs/styles.module.css +2 -17
  108. package/src/theme/DocCard/index.tsx +24 -17
  109. package/src/theme/DocCard/styles.module.css +8 -17
  110. package/src/theme/DocCardList/index.tsx +14 -3
  111. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +31 -4
  112. package/src/theme/DocItem/index.tsx +71 -55
  113. package/src/theme/DocPage/index.tsx +89 -90
  114. package/src/theme/DocPage/styles.module.css +0 -4
  115. package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
  116. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +44 -0
  117. package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
  118. package/src/theme/DocSidebar/Desktop/Content/styles.module.css +17 -0
  119. package/src/theme/DocSidebar/Desktop/index.tsx +38 -0
  120. package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
  121. package/src/theme/DocSidebar/Mobile/index.tsx +54 -0
  122. package/src/theme/DocSidebar/index.tsx +6 -121
  123. package/src/theme/DocSidebarItem/index.tsx +15 -16
  124. package/src/theme/DocSidebarItem/styles.module.css +4 -0
  125. package/src/theme/DocTagDocListPage/index.tsx +38 -30
  126. package/src/theme/DocTagsListPage/index.tsx +21 -16
  127. package/src/theme/DocVersionBanner/index.tsx +3 -4
  128. package/src/theme/Footer/Copyright/index.tsx +20 -0
  129. package/src/theme/Footer/Layout/index.tsx +34 -0
  130. package/src/theme/Footer/LinkItem/index.tsx +36 -0
  131. package/src/theme/Footer/Links/MultiColumn/index.tsx +51 -0
  132. package/src/theme/Footer/Links/Simple/index.tsx +42 -0
  133. package/src/theme/Footer/Links/index.tsx +21 -0
  134. package/src/theme/Footer/Logo/index.tsx +41 -0
  135. package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
  136. package/src/theme/Footer/index.tsx +12 -186
  137. package/src/theme/Heading/index.tsx +6 -4
  138. package/src/theme/IconExternalLink/styles.module.css +0 -2
  139. package/src/theme/Layout/index.tsx +15 -10
  140. package/src/theme/LayoutProviders/index.tsx +5 -4
  141. package/src/theme/MDXComponents/A.tsx +14 -0
  142. package/src/theme/MDXComponents/Code.tsx +37 -0
  143. package/src/theme/MDXComponents/Details.tsx +26 -0
  144. package/src/theme/MDXComponents/Head.tsx +29 -0
  145. package/src/theme/MDXComponents/Heading.tsx +14 -0
  146. package/src/theme/MDXComponents/Img.module.css +10 -0
  147. package/src/theme/MDXComponents/Img.tsx +26 -0
  148. package/src/theme/MDXComponents/Pre.tsx +22 -0
  149. package/{lib-next/theme/MDXComponents/styles.css → src/theme/MDXComponents/Ul.module.css} +1 -5
  150. package/src/theme/MDXComponents/Ul.tsx +28 -0
  151. package/src/theme/MDXComponents/index.tsx +23 -80
  152. package/src/theme/MDXContent/index.tsx +15 -0
  153. package/src/theme/MDXPage/index.tsx +33 -28
  154. package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
  155. package/src/theme/Navbar/Content/index.tsx +81 -0
  156. package/src/theme/Navbar/Content/styles.module.css +15 -0
  157. package/src/theme/Navbar/Layout/index.tsx +57 -0
  158. package/{lib-next/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -13
  159. package/src/theme/Navbar/Logo/index.tsx +19 -0
  160. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
  161. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
  162. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
  163. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
  164. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
  165. package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
  166. package/src/theme/Navbar/index.tsx +6 -286
  167. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +2 -2
  168. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +11 -2
  169. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +1 -1
  170. package/src/theme/NavbarItem/NavbarNavLink.tsx +3 -7
  171. package/src/theme/NavbarItem/index.tsx +3 -4
  172. package/src/theme/NotFound.tsx +38 -33
  173. package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +11 -25
  174. package/src/theme/TOCCollapsible/index.tsx +1 -3
  175. package/src/theme/Tabs/index.tsx +5 -6
  176. package/src/theme/Tag/index.tsx +4 -4
  177. package/src/theme/ThemedImage/index.tsx +4 -3
  178. package/src/theme-classic.d.ts +286 -60
  179. package/src/translations.ts +12 -6
  180. package/src/validateThemeConfig.ts +6 -6
  181. package/lib-next/theme/DocSidebar/styles.module.css +0 -107
  182. package/lib-next/theme/Seo/index.js +0 -40
  183. package/src/theme/DocSidebar/styles.module.css +0 -107
  184. package/src/theme/Seo/index.tsx +0 -49
@@ -6,28 +6,11 @@
6
6
  */
7
7
 
8
8
  .toggle {
9
- position: relative;
10
- width: 32px;
11
- height: 32px;
12
- }
13
-
14
- .toggleScreenReader {
15
- border: 0;
16
- clip: rect(0 0 0 0);
17
- height: 1px;
18
- margin: -1px;
19
- overflow: hidden;
20
- position: absolute;
21
- width: 1px;
22
- }
23
-
24
- .toggleDisabled {
25
- cursor: not-allowed;
9
+ width: 2rem;
10
+ height: 2rem;
26
11
  }
27
12
 
28
13
  .toggleButton {
29
- cursor: pointer;
30
- user-select: none;
31
14
  -webkit-tap-highlight-color: transparent;
32
15
  align-items: center;
33
16
  display: flex;
@@ -35,17 +18,18 @@
35
18
  width: 100%;
36
19
  height: 100%;
37
20
  border-radius: 50%;
21
+ transition: background var(--ifm-transition-fast);
38
22
  }
39
23
 
40
24
  .toggleButton:hover {
41
- background-color: #00000010;
42
- }
43
-
44
- [data-theme='dark'] .toggleButton:hover {
45
- background-color: #ffffff20;
25
+ background: var(--ifm-color-emphasis-200);
46
26
  }
47
27
 
48
28
  [data-theme='light'] .darkToggleIcon,
49
29
  [data-theme='dark'] .lightToggleIcon {
50
30
  display: none;
51
31
  }
32
+
33
+ .toggleButtonDisabled {
34
+ cursor: not-allowed;
35
+ }
@@ -24,13 +24,15 @@ function BreadcrumbsItemLink({
24
24
  children: ReactNode;
25
25
  href?: string;
26
26
  }): JSX.Element {
27
- const className = clsx('breadcrumbs__link', styles.breadcrumbsItemLink);
27
+ const className = 'breadcrumbs__link';
28
28
  return href ? (
29
- <Link className={className} href={href}>
30
- {children}
29
+ <Link className={className} href={href} itemProp="item">
30
+ <span itemProp="name">{children}</span>
31
31
  </Link>
32
32
  ) : (
33
- <span className={className}>{children}</span>
33
+ <span className={className} itemProp="item name">
34
+ {children}
35
+ </span>
34
36
  );
35
37
  }
36
38
 
@@ -38,16 +40,22 @@ function BreadcrumbsItemLink({
38
40
  function BreadcrumbsItem({
39
41
  children,
40
42
  active,
43
+ index,
41
44
  }: {
42
45
  children: ReactNode;
43
46
  active?: boolean;
47
+ index: number;
44
48
  }): JSX.Element {
45
49
  return (
46
50
  <li
51
+ itemScope
52
+ itemProp="itemListElement"
53
+ itemType="https://schema.org/ListItem"
47
54
  className={clsx('breadcrumbs__item', {
48
55
  'breadcrumbs__item--active': active,
49
56
  })}>
50
57
  {children}
58
+ <meta itemProp="position" content={String(index + 1)} />
51
59
  </li>
52
60
  );
53
61
  }
@@ -55,9 +63,13 @@ function BreadcrumbsItem({
55
63
  function HomeBreadcrumbItem() {
56
64
  const homeHref = useBaseUrl('/');
57
65
  return (
58
- <BreadcrumbsItem>
59
- <BreadcrumbsItemLink href={homeHref}>🏠</BreadcrumbsItemLink>
60
- </BreadcrumbsItem>
66
+ <li className="breadcrumbs__item">
67
+ <Link
68
+ className={clsx('breadcrumbs__link', styles.breadcrumbsItemLink)}
69
+ href={homeHref}>
70
+ 🏠
71
+ </Link>
72
+ </li>
61
73
  );
62
74
  }
63
75
 
@@ -76,11 +88,18 @@ export default function DocBreadcrumbs(): JSX.Element | null {
76
88
  styles.breadcrumbsContainer,
77
89
  )}
78
90
  aria-label="breadcrumbs">
79
- <ul className="breadcrumbs">
91
+ <ul
92
+ className="breadcrumbs"
93
+ itemScope
94
+ itemType="https://schema.org/BreadcrumbList">
80
95
  {homePageRoute && <HomeBreadcrumbItem />}
81
96
  {breadcrumbs.map((item, idx) => (
82
- <BreadcrumbsItem key={idx} active={idx === breadcrumbs.length - 1}>
83
- <BreadcrumbsItemLink href={item.href}>
97
+ <BreadcrumbsItem
98
+ key={idx}
99
+ active={idx === breadcrumbs.length - 1}
100
+ index={idx}>
101
+ <BreadcrumbsItemLink
102
+ href={idx < breadcrumbs.length - 1 ? item.href : undefined}>
84
103
  {item.label}
85
104
  </BreadcrumbsItemLink>
86
105
  </BreadcrumbsItem>
@@ -6,21 +6,6 @@
6
6
  */
7
7
 
8
8
  .breadcrumbsContainer {
9
- margin-bottom: 0.4rem;
10
- }
11
-
12
- .breadcrumbsItemLink {
13
- --ifm-breadcrumb-size-multiplier: 0.7 !important;
14
- margin-bottom: 0.4rem;
15
- background: var(--ifm-color-gray-100);
16
- }
17
-
18
- html[data-theme='dark'] .breadcrumbsItemLink {
19
- background-color: var(--ifm-color-gray-900);
20
- }
21
-
22
- @media (min-width: 997px) {
23
- .breadcrumbsItemLink {
24
- --ifm-breadcrumb-size-multiplier: 0.8;
25
- }
9
+ --ifm-breadcrumb-size-multiplier: 0.8;
10
+ margin-bottom: 0.8rem;
26
11
  }
@@ -22,20 +22,15 @@ function CardContainer({
22
22
  href,
23
23
  children,
24
24
  }: {
25
- href?: string;
25
+ href: string;
26
26
  children: ReactNode;
27
27
  }): JSX.Element {
28
- const className = clsx(
29
- 'card margin-bottom--lg padding--lg',
30
- styles.cardContainer,
31
- href && styles.cardContainerLink,
32
- );
33
- return href ? (
34
- <Link href={href} className={className}>
28
+ return (
29
+ <Link
30
+ href={href}
31
+ className={clsx('card padding--lg', styles.cardContainer)}>
35
32
  {children}
36
33
  </Link>
37
- ) : (
38
- <div className={className}>{children}</div>
39
34
  );
40
35
  }
41
36
 
@@ -45,7 +40,7 @@ function CardLayout({
45
40
  title,
46
41
  description,
47
42
  }: {
48
- href?: string;
43
+ href: string;
49
44
  icon: ReactNode;
50
45
  title: string;
51
46
  description?: string;
@@ -55,17 +50,29 @@ function CardLayout({
55
50
  <h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
56
51
  {icon} {title}
57
52
  </h2>
58
- <div
59
- className={clsx('text--truncate', styles.cardDescription)}
60
- title={description}>
61
- {description}
62
- </div>
53
+ {description && (
54
+ <p
55
+ className={clsx('text--truncate', styles.cardDescription)}
56
+ title={description}>
57
+ {description}
58
+ </p>
59
+ )}
63
60
  </CardContainer>
64
61
  );
65
62
  }
66
63
 
67
- function CardCategory({item}: {item: PropSidebarItemCategory}): JSX.Element {
64
+ function CardCategory({
65
+ item,
66
+ }: {
67
+ item: PropSidebarItemCategory;
68
+ }): JSX.Element | null {
68
69
  const href = findFirstCategoryLink(item);
70
+
71
+ // Unexpected: categories that don't have a link have been filtered upfront
72
+ if (!href) {
73
+ return null;
74
+ }
75
+
69
76
  return (
70
77
  <CardLayout
71
78
  href={href}
@@ -6,38 +6,29 @@
6
6
  */
7
7
 
8
8
  .cardContainer {
9
- height: 8rem;
10
- color: var(--ifm-color-emphasis-800);
11
9
  --ifm-link-color: var(--ifm-color-emphasis-800);
12
- --ifm-link-hover-color: var(--ifm-color-emphasis-800);
10
+ --ifm-link-hover-color: var(--ifm-color-emphasis-700);
13
11
  --ifm-link-hover-decoration: none;
14
12
 
15
- /* box-shadow: var(--ifm-global-shadow-lw); */
16
13
  box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
17
14
  border: 1px solid var(--ifm-color-emphasis-200);
18
- transition: box-shadow var(--ifm-transition-fast) ease,
19
- background-color var(--ifm-transition-fast) ease;
15
+ transition: all var(--ifm-transition-fast) ease;
16
+ transition-property: border, box-shadow;
20
17
  }
21
18
 
22
- .cardContainer.cardContainerLink:hover {
23
- /* box-shadow: var(--ifm-global-shadow-md); */
24
- box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
19
+ .cardContainer:hover {
20
+ border-color: var(--ifm-color-primary);
21
+ box-shadow: 0 3px 6px 0 rgb(0 0 0 / 20%);
25
22
  }
26
23
 
27
- [data-theme='dark'] .cardContainer.cardContainerLink:hover {
28
- --ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
29
- }
30
-
31
- .cardContainer:not(.cardContainerLink) {
32
- cursor: not-allowed;
24
+ .cardContainer *:last-child {
25
+ margin-bottom: 0;
33
26
  }
34
27
 
35
28
  .cardTitle {
36
29
  font-size: 1.2rem;
37
- min-height: 1.2rem;
38
30
  }
39
31
 
40
32
  .cardDescription {
41
33
  font-size: 0.8rem;
42
- min-height: 0.8rem;
43
34
  }
@@ -9,6 +9,17 @@ import React from 'react';
9
9
 
10
10
  import DocCard from '@theme/DocCard';
11
11
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
12
+ import {findFirstCategoryLink} from '@docusaurus/theme-common';
13
+
14
+ // Filter categories that don't have a link.
15
+ function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
16
+ return items.filter((item) => {
17
+ if (item.type === 'category') {
18
+ return !!findFirstCategoryLink(item);
19
+ }
20
+ return true;
21
+ });
22
+ }
12
23
 
13
24
  export default function DocCardList({
14
25
  items,
@@ -17,9 +28,9 @@ export default function DocCardList({
17
28
  }): JSX.Element {
18
29
  return (
19
30
  <div className="row">
20
- {items.map((item, index) => (
21
- <article key={index} className="col col--6">
22
- <DocCard item={item} />
31
+ {filterItems(items).map((item, index) => (
32
+ <article key={index} className="col col--6 margin-bottom--lg">
33
+ <DocCard key={index} item={item} />
23
34
  </article>
24
35
  ))}
25
36
  </div>
@@ -6,11 +6,13 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
9
+ import {
10
+ PageMetadata,
11
+ useCurrentSidebarCategory,
12
+ } from '@docusaurus/theme-common';
10
13
  import type {Props} from '@theme/DocCategoryGeneratedIndexPage';
11
14
  import DocCardList from '@theme/DocCardList';
12
15
  import DocPaginator from '@theme/DocPaginator';
13
- import Seo from '@theme/Seo';
14
16
  import DocVersionBanner from '@theme/DocVersionBanner';
15
17
  import DocVersionBadge from '@theme/DocVersionBadge';
16
18
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
@@ -19,13 +21,27 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
19
21
 
20
22
  import styles from './styles.module.css';
21
23
 
22
- export default function DocCategoryGeneratedIndexPage({
24
+ function DocCategoryGeneratedIndexPageMetadata({
25
+ categoryGeneratedIndex,
26
+ }: Props): JSX.Element {
27
+ return (
28
+ <PageMetadata
29
+ title={categoryGeneratedIndex.title}
30
+ description={categoryGeneratedIndex.description}
31
+ keywords={categoryGeneratedIndex.keywords}
32
+ // TODO `require` this?
33
+ image={useBaseUrl(categoryGeneratedIndex.image)}
34
+ />
35
+ );
36
+ }
37
+
38
+ function DocCategoryGeneratedIndexPageContent({
23
39
  categoryGeneratedIndex,
24
40
  }: Props): JSX.Element {
25
41
  const category = useCurrentSidebarCategory();
26
42
  return (
27
43
  <>
28
- <Seo
44
+ <PageMetadata
29
45
  title={categoryGeneratedIndex.title}
30
46
  description={categoryGeneratedIndex.description}
31
47
  keywords={categoryGeneratedIndex.keywords}
@@ -57,3 +73,14 @@ export default function DocCategoryGeneratedIndexPage({
57
73
  </>
58
74
  );
59
75
  }
76
+
77
+ export default function DocCategoryGeneratedIndexPage(
78
+ props: Props,
79
+ ): JSX.Element {
80
+ return (
81
+ <>
82
+ <DocCategoryGeneratedIndexPageMetadata {...props} />
83
+ <DocCategoryGeneratedIndexPageContent {...props} />
84
+ </>
85
+ );
86
+ }
@@ -10,28 +10,41 @@ import clsx from 'clsx';
10
10
  import DocPaginator from '@theme/DocPaginator';
11
11
  import DocVersionBanner from '@theme/DocVersionBanner';
12
12
  import DocVersionBadge from '@theme/DocVersionBadge';
13
- import Seo from '@theme/Seo';
14
13
  import type {Props} from '@theme/DocItem';
15
14
  import DocItemFooter from '@theme/DocItemFooter';
16
15
  import TOC from '@theme/TOC';
17
16
  import TOCCollapsible from '@theme/TOCCollapsible';
18
17
  import Heading from '@theme/Heading';
19
18
  import styles from './styles.module.css';
20
- import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
19
+ import {
20
+ PageMetadata,
21
+ HtmlClassNameProvider,
22
+ ThemeClassNames,
23
+ useWindowSize,
24
+ } from '@docusaurus/theme-common';
21
25
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
26
+ import MDXContent from '@theme/MDXContent';
22
27
 
23
- export default function DocItem(props: Props): JSX.Element {
28
+ function DocItemMetadata(props: Props): JSX.Element {
24
29
  const {content: DocContent} = props;
25
30
  const {metadata, frontMatter, assets} = DocContent;
31
+ const {keywords} = frontMatter;
32
+ const {description, title} = metadata;
33
+ const image = assets.image ?? frontMatter.image;
34
+
35
+ return <PageMetadata {...{title, description, keywords, image}} />;
36
+ }
37
+
38
+ function DocItemContent(props: Props): JSX.Element {
39
+ const {content: DocContent} = props;
40
+ const {metadata, frontMatter} = DocContent;
26
41
  const {
27
- keywords,
28
42
  hide_title: hideTitle,
29
43
  hide_table_of_contents: hideTableOfContents,
30
44
  toc_min_heading_level: tocMinHeadingLevel,
31
45
  toc_max_heading_level: tocMaxHeadingLevel,
32
46
  } = frontMatter;
33
- const {description, title} = metadata;
34
- const image = assets.image ?? frontMatter.image;
47
+ const {title} = metadata;
35
48
 
36
49
  // We only add a title if:
37
50
  // - user asks to hide it with front matter
@@ -48,66 +61,69 @@ export default function DocItem(props: Props): JSX.Element {
48
61
  canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr');
49
62
 
50
63
  return (
51
- <>
52
- <Seo {...{title, description, keywords, image}} />
64
+ <div className="row">
65
+ <div className={clsx('col', !hideTableOfContents && styles.docItemCol)}>
66
+ <DocVersionBanner />
67
+ <div className={styles.docItemContainer}>
68
+ <article>
69
+ <DocBreadcrumbs />
70
+ <DocVersionBadge />
53
71
 
54
- <div className="row">
55
- <div
56
- className={clsx('col', {
57
- [styles.docItemCol]: !hideTableOfContents,
58
- })}>
59
- <DocVersionBanner />
60
- <div className={styles.docItemContainer}>
61
- <article>
62
- <DocBreadcrumbs />
63
- <DocVersionBadge />
64
-
65
- {canRenderTOC && (
66
- <TOCCollapsible
67
- toc={DocContent.toc}
68
- minHeadingLevel={tocMinHeadingLevel}
69
- maxHeadingLevel={tocMaxHeadingLevel}
70
- className={clsx(
71
- ThemeClassNames.docs.docTocMobile,
72
- styles.tocMobile,
73
- )}
74
- />
75
- )}
72
+ {canRenderTOC && (
73
+ <TOCCollapsible
74
+ toc={DocContent.toc}
75
+ minHeadingLevel={tocMinHeadingLevel}
76
+ maxHeadingLevel={tocMaxHeadingLevel}
77
+ className={clsx(
78
+ ThemeClassNames.docs.docTocMobile,
79
+ styles.tocMobile,
80
+ )}
81
+ />
82
+ )}
76
83
 
77
- <div
78
- className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
79
- {/*
84
+ <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
85
+ {/*
80
86
  Title can be declared inside md content or declared through
81
87
  front matter and added manually. To make both cases consistent,
82
88
  the added title is added under the same div.markdown block
83
89
  See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
84
90
  */}
85
- {shouldAddTitle && (
86
- <header>
87
- <Heading as="h1">{title}</Heading>
88
- </header>
89
- )}
90
-
91
+ {shouldAddTitle && (
92
+ <header>
93
+ <Heading as="h1">{title}</Heading>
94
+ </header>
95
+ )}
96
+ <MDXContent>
91
97
  <DocContent />
92
- </div>
98
+ </MDXContent>
99
+ </div>
93
100
 
94
- <DocItemFooter {...props} />
95
- </article>
101
+ <DocItemFooter {...props} />
102
+ </article>
96
103
 
97
- <DocPaginator previous={metadata.previous} next={metadata.next} />
98
- </div>
104
+ <DocPaginator previous={metadata.previous} next={metadata.next} />
99
105
  </div>
100
- {renderTocDesktop && (
101
- <div className="col col--3">
102
- <TOC
103
- toc={DocContent.toc}
104
- minHeadingLevel={tocMinHeadingLevel}
105
- maxHeadingLevel={tocMaxHeadingLevel}
106
- className={ThemeClassNames.docs.docTocDesktop}
107
- />
108
- </div>
109
- )}
110
106
  </div>
111
- </>
107
+ {renderTocDesktop && (
108
+ <div className="col col--3">
109
+ <TOC
110
+ toc={DocContent.toc}
111
+ minHeadingLevel={tocMinHeadingLevel}
112
+ maxHeadingLevel={tocMaxHeadingLevel}
113
+ className={ThemeClassNames.docs.docTocDesktop}
114
+ />
115
+ </div>
116
+ )}
117
+ </div>
118
+ );
119
+ }
120
+
121
+ export default function DocItem(props: Props): JSX.Element {
122
+ const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
123
+ return (
124
+ <HtmlClassNameProvider className={docHtmlClassName}>
125
+ <DocItemMetadata {...props} />
126
+ <DocItemContent {...props} />
127
+ </HtmlClassNameProvider>
112
128
  );
113
129
  }