@docusaurus/theme-classic 2.0.0-beta.21 → 2.0.0-beta.22

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 (240) hide show
  1. package/lib/getSwizzleConfig.js +5 -5
  2. package/lib/index.js +4 -2
  3. package/lib/theme/Admonition/index.d.ts +1 -1
  4. package/lib/theme/Admonition/index.js +139 -57
  5. package/lib/{admonitions.css → theme/Admonition/styles.module.css} +14 -15
  6. package/lib/theme/AnnouncementBar/index.js +3 -2
  7. package/lib/theme/BackToTopButton/index.js +2 -1
  8. package/lib/theme/BlogListPage/index.js +2 -11
  9. package/lib/theme/BlogPostItem/Container/index.d.ts +9 -0
  10. package/lib/theme/BlogPostItem/Container/index.js +26 -0
  11. package/lib/theme/BlogPostItem/Content/index.d.ts +9 -0
  12. package/lib/theme/BlogPostItem/Content/index.js +23 -0
  13. package/lib/theme/BlogPostItem/Footer/ReadMoreLink/index.d.ts +9 -0
  14. package/lib/theme/BlogPostItem/Footer/ReadMoreLink/index.js +38 -0
  15. package/lib/theme/BlogPostItem/Footer/index.d.ts +8 -0
  16. package/lib/theme/BlogPostItem/Footer/index.js +52 -0
  17. package/lib/theme/BlogPostItem/Footer/styles.module.css +10 -0
  18. package/lib/theme/BlogPostItem/Header/Author/index.d.ts +9 -0
  19. package/lib/theme/{BlogPostAuthor → BlogPostItem/Header/Author}/index.js +3 -2
  20. package/lib/theme/BlogPostItem/Header/Authors/index.d.ts +9 -0
  21. package/{src/theme/BlogPostAuthors/index.tsx → lib/theme/BlogPostItem/Header/Authors/index.js} +9 -10
  22. package/lib/theme/{BlogPostAuthors → BlogPostItem/Header/Authors}/styles.module.css +0 -0
  23. package/lib/theme/{BlogPostAuthors → BlogPostItem/Header/Info}/index.d.ts +2 -2
  24. package/lib/theme/BlogPostItem/Header/Info/index.js +60 -0
  25. package/lib/theme/BlogPostItem/Header/Info/styles.module.css +10 -0
  26. package/lib/theme/BlogPostItem/Header/Title/index.d.ts +9 -0
  27. package/lib/theme/BlogPostItem/Header/Title/index.js +27 -0
  28. package/{src/theme/BlogPostItem → lib/theme/BlogPostItem/Header/Title}/styles.module.css +2 -10
  29. package/lib/theme/BlogPostItem/Header/index.d.ts +8 -0
  30. package/lib/theme/BlogPostItem/Header/index.js +19 -0
  31. package/lib/theme/BlogPostItem/index.d.ts +1 -1
  32. package/lib/theme/BlogPostItem/index.js +16 -142
  33. package/lib/theme/BlogPostItems/index.d.ts +9 -0
  34. package/lib/theme/BlogPostItems/index.js +27 -0
  35. package/lib/theme/BlogPostPage/Metadata/index.d.ts +8 -0
  36. package/lib/theme/BlogPostPage/Metadata/index.js +41 -0
  37. package/lib/theme/BlogPostPage/index.js +21 -60
  38. package/lib/theme/BlogTagsListPage/index.js +1 -1
  39. package/lib/theme/BlogTagsPostsPage/index.d.ts +1 -1
  40. package/lib/theme/BlogTagsPostsPage/index.js +36 -30
  41. package/lib/theme/CodeBlock/Container/index.js +2 -5
  42. package/lib/theme/CodeBlock/Content/String.js +2 -3
  43. package/lib/theme/CodeBlock/CopyButton/index.js +1 -0
  44. package/lib/theme/CodeBlock/Line/styles.module.css +7 -7
  45. package/lib/theme/ColorModeToggle/index.js +2 -2
  46. package/lib/theme/DocBreadcrumbs/index.js +3 -3
  47. package/lib/theme/DocCard/index.js +4 -1
  48. package/lib/theme/DocCardList/index.js +2 -2
  49. package/lib/theme/DocItem/Content/index.d.ts +9 -0
  50. package/lib/theme/DocItem/Content/index.js +44 -0
  51. package/lib/theme/DocItem/Footer/index.d.ts +8 -0
  52. package/lib/theme/{DocItemFooter → DocItem/Footer}/index.js +3 -3
  53. package/lib/theme/{DocItemFooter → DocItem/Footer}/styles.module.css +0 -0
  54. package/lib/theme/{BlogPostAuthor → DocItem/Layout}/index.d.ts +2 -2
  55. package/lib/theme/DocItem/Layout/index.js +59 -0
  56. package/lib/theme/DocItem/Layout/styles.module.css +17 -0
  57. package/lib/theme/DocItem/Metadata/index.d.ts +8 -0
  58. package/lib/theme/DocItem/Metadata/index.js +20 -0
  59. package/lib/theme/{DocItemFooter → DocItem/Paginator}/index.d.ts +5 -3
  60. package/lib/theme/DocItem/Paginator/index.js +17 -0
  61. package/lib/theme/DocItem/TOC/Desktop/index.d.ts +8 -0
  62. package/lib/theme/DocItem/TOC/Desktop/index.js +21 -0
  63. package/lib/theme/DocItem/TOC/Mobile/index.d.ts +8 -0
  64. package/lib/theme/DocItem/TOC/Mobile/index.js +23 -0
  65. package/lib/theme/DocItem/{styles.module.css → TOC/Mobile/styles.module.css} +0 -9
  66. package/lib/theme/DocItem/index.js +13 -106
  67. package/lib/theme/DocPage/Layout/Main/index.js +1 -1
  68. package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +1 -1
  69. package/lib/theme/DocPage/Layout/Sidebar/index.js +2 -1
  70. package/lib/theme/DocPage/Layout/index.js +1 -1
  71. package/lib/theme/DocPage/index.js +2 -3
  72. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.js +1 -1
  73. package/lib/theme/DocSidebar/Desktop/Content/index.js +2 -2
  74. package/lib/theme/DocSidebar/Mobile/index.js +1 -1
  75. package/lib/theme/DocSidebarItem/Category/index.js +6 -4
  76. package/lib/theme/DocSidebarItem/Link/index.js +3 -2
  77. package/lib/theme/DocSidebarItems/index.js +1 -1
  78. package/lib/theme/DocVersionBadge/index.js +2 -1
  79. package/lib/theme/DocVersionBanner/index.js +2 -2
  80. package/lib/theme/EditThisPage/index.js +1 -1
  81. package/lib/theme/Footer/LinkItem/index.js +1 -1
  82. package/lib/theme/Footer/Logo/index.js +7 -2
  83. package/lib/theme/{IconArrow → Icon/Arrow}/index.d.ts +1 -1
  84. package/lib/theme/{IconArrow → Icon/Arrow}/index.js +0 -0
  85. package/lib/theme/{IconClose → Icon/Close}/index.d.ts +1 -1
  86. package/lib/theme/{IconClose → Icon/Close}/index.js +0 -0
  87. package/lib/theme/{IconDarkMode → Icon/DarkMode}/index.d.ts +1 -1
  88. package/lib/theme/{IconDarkMode → Icon/DarkMode}/index.js +0 -0
  89. package/lib/theme/{IconEdit → Icon/Edit}/index.d.ts +1 -1
  90. package/lib/theme/{IconEdit → Icon/Edit}/index.js +0 -0
  91. package/lib/theme/{IconEdit → Icon/Edit}/styles.module.css +0 -0
  92. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/index.d.ts +1 -1
  93. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/index.js +0 -0
  94. package/lib/theme/{IconExternalLink → Icon/ExternalLink}/styles.module.css +0 -0
  95. package/lib/theme/{IconHome → Icon/Home}/index.d.ts +1 -1
  96. package/lib/theme/{IconHome → Icon/Home}/index.js +0 -0
  97. package/lib/theme/{IconLanguage → Icon/Language}/index.d.ts +1 -1
  98. package/lib/theme/{IconLanguage → Icon/Language}/index.js +0 -0
  99. package/lib/theme/{IconLightMode → Icon/LightMode}/index.d.ts +1 -1
  100. package/lib/theme/{IconLightMode → Icon/LightMode}/index.js +0 -0
  101. package/lib/theme/{IconMenu → Icon/Menu}/index.d.ts +1 -1
  102. package/lib/theme/{IconMenu → Icon/Menu}/index.js +0 -0
  103. package/lib/theme/Layout/Provider/index.d.ts +9 -0
  104. package/lib/theme/Layout/Provider/index.js +29 -0
  105. package/lib/theme/Layout/index.d.ts +0 -1
  106. package/lib/theme/Layout/index.js +12 -10
  107. package/{src/theme/Layout/styles.css → lib/theme/Layout/styles.module.css} +10 -12
  108. package/lib/theme/Logo/index.js +35 -17
  109. package/lib/theme/MDXComponents/Code.js +1 -1
  110. package/lib/theme/MDXComponents/index.js +2 -0
  111. package/lib/theme/MDXPage/index.js +6 -4
  112. package/lib/theme/Navbar/Content/index.js +2 -2
  113. package/lib/theme/Navbar/Layout/index.js +2 -2
  114. package/lib/theme/Navbar/MobileSidebar/Header/index.js +2 -2
  115. package/lib/theme/Navbar/MobileSidebar/Layout/index.js +1 -1
  116. package/lib/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +2 -1
  117. package/lib/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +2 -1
  118. package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +2 -2
  119. package/lib/theme/Navbar/MobileSidebar/index.js +1 -1
  120. package/lib/theme/NavbarItem/DocNavbarItem.js +1 -1
  121. package/lib/theme/NavbarItem/DocSidebarNavbarItem.js +1 -1
  122. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -4
  123. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +1 -1
  124. package/lib/theme/NavbarItem/DropdownNavbarItem.js +2 -3
  125. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -2
  126. package/lib/theme/NavbarItem/NavbarNavLink.js +1 -1
  127. package/lib/theme/SiteMetadata/index.js +2 -3
  128. package/lib/theme/SkipToContent/index.js +1 -1
  129. package/lib/theme/TOCItems/index.js +2 -2
  130. package/lib/theme/Tabs/index.js +2 -2
  131. package/lib/validateThemeConfig.js +13 -18
  132. package/package.json +19 -15
  133. package/src/getSwizzleConfig.ts +5 -5
  134. package/src/index.ts +4 -2
  135. package/src/theme/Admonition/index.tsx +161 -58
  136. package/src/{admonitions.css → theme/Admonition/styles.module.css} +14 -15
  137. package/src/theme/AnnouncementBar/index.tsx +3 -2
  138. package/src/theme/BackToTopButton/index.tsx +2 -1
  139. package/src/theme/BlogListPage/index.tsx +2 -11
  140. package/src/theme/BlogPostItem/Container/index.tsx +32 -0
  141. package/src/theme/BlogPostItem/Content/index.tsx +29 -0
  142. package/src/theme/BlogPostItem/Footer/ReadMoreLink/index.tsx +44 -0
  143. package/src/theme/BlogPostItem/Footer/index.tsx +60 -0
  144. package/src/theme/BlogPostItem/Footer/styles.module.css +10 -0
  145. package/src/theme/{BlogPostAuthor → BlogPostItem/Header/Author}/index.tsx +8 -3
  146. package/{lib/theme/BlogPostAuthors/index.js → src/theme/BlogPostItem/Header/Authors/index.tsx} +14 -3
  147. package/src/theme/{BlogPostAuthors → BlogPostItem/Header/Authors}/styles.module.css +0 -0
  148. package/src/theme/BlogPostItem/Header/Info/index.tsx +71 -0
  149. package/src/theme/BlogPostItem/Header/Info/styles.module.css +10 -0
  150. package/src/theme/BlogPostItem/Header/Title/index.tsx +33 -0
  151. package/{lib/theme/BlogPostItem → src/theme/BlogPostItem/Header/Title}/styles.module.css +2 -10
  152. package/src/theme/BlogPostItem/Header/index.tsx +21 -0
  153. package/src/theme/BlogPostItem/index.tsx +19 -145
  154. package/src/theme/BlogPostItems/index.tsx +30 -0
  155. package/src/theme/BlogPostPage/Metadata/index.tsx +44 -0
  156. package/src/theme/BlogPostPage/index.tsx +29 -62
  157. package/src/theme/BlogTagsListPage/index.tsx +1 -1
  158. package/src/theme/BlogTagsPostsPage/index.tsx +42 -35
  159. package/src/theme/CodeBlock/Container/index.tsx +3 -6
  160. package/src/theme/CodeBlock/Content/String.tsx +2 -3
  161. package/src/theme/CodeBlock/CopyButton/index.tsx +1 -0
  162. package/src/theme/CodeBlock/Line/styles.module.css +7 -7
  163. package/src/theme/ColorModeToggle/index.tsx +2 -2
  164. package/src/theme/DocBreadcrumbs/index.tsx +3 -3
  165. package/src/theme/DocCard/index.tsx +4 -1
  166. package/src/theme/DocCardList/index.tsx +2 -2
  167. package/src/theme/DocItem/Content/index.tsx +48 -0
  168. package/src/theme/{DocItemFooter → DocItem/Footer}/index.tsx +4 -5
  169. package/src/theme/{DocItemFooter → DocItem/Footer}/styles.module.css +0 -0
  170. package/src/theme/DocItem/Layout/index.tsx +68 -0
  171. package/src/theme/DocItem/Layout/styles.module.css +17 -0
  172. package/src/theme/DocItem/Metadata/index.tsx +22 -0
  173. package/src/theme/DocItem/Paginator/index.tsx +19 -0
  174. package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
  175. package/src/theme/DocItem/TOC/Mobile/index.tsx +27 -0
  176. package/src/theme/DocItem/{styles.module.css → TOC/Mobile/styles.module.css} +0 -9
  177. package/src/theme/DocItem/index.tsx +13 -115
  178. package/src/theme/DocPage/Layout/Main/index.tsx +1 -1
  179. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +1 -1
  180. package/src/theme/DocPage/Layout/Sidebar/index.tsx +2 -1
  181. package/src/theme/DocPage/Layout/index.tsx +1 -1
  182. package/src/theme/DocPage/index.tsx +2 -3
  183. package/src/theme/DocPaginator/index.tsx +0 -1
  184. package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +1 -1
  185. package/src/theme/DocSidebar/Desktop/Content/index.tsx +2 -2
  186. package/src/theme/DocSidebar/Mobile/index.tsx +1 -1
  187. package/src/theme/DocSidebarItem/Category/index.tsx +6 -4
  188. package/src/theme/DocSidebarItem/Link/index.tsx +3 -2
  189. package/src/theme/DocSidebarItems/index.tsx +1 -1
  190. package/src/theme/DocVersionBadge/index.tsx +2 -1
  191. package/src/theme/DocVersionBanner/index.tsx +2 -3
  192. package/src/theme/EditThisPage/index.tsx +1 -1
  193. package/src/theme/Footer/LinkItem/index.tsx +1 -1
  194. package/src/theme/Footer/Logo/index.tsx +7 -2
  195. package/src/theme/{IconArrow → Icon/Arrow}/index.tsx +1 -1
  196. package/src/theme/{IconClose → Icon/Close}/index.tsx +1 -1
  197. package/src/theme/{IconDarkMode → Icon/DarkMode}/index.tsx +1 -1
  198. package/src/theme/{IconEdit → Icon/Edit}/index.tsx +1 -1
  199. package/src/theme/{IconEdit → Icon/Edit}/styles.module.css +0 -0
  200. package/src/theme/{IconExternalLink → Icon/ExternalLink}/index.tsx +1 -1
  201. package/src/theme/{IconExternalLink → Icon/ExternalLink}/styles.module.css +0 -0
  202. package/src/theme/{IconHome → Icon/Home}/index.tsx +1 -1
  203. package/src/theme/{IconLanguage → Icon/Language}/index.tsx +1 -1
  204. package/src/theme/{IconLightMode → Icon/LightMode}/index.tsx +1 -1
  205. package/src/theme/{IconMenu → Icon/Menu}/index.tsx +1 -1
  206. package/src/theme/Layout/Provider/index.tsx +33 -0
  207. package/src/theme/Layout/index.tsx +12 -10
  208. package/{lib/theme/Layout/styles.css → src/theme/Layout/styles.module.css} +10 -12
  209. package/src/theme/Logo/index.tsx +49 -19
  210. package/src/theme/MDXComponents/Code.tsx +5 -2
  211. package/src/theme/MDXComponents/Details.tsx +2 -1
  212. package/src/theme/MDXComponents/Head.tsx +3 -5
  213. package/src/theme/MDXComponents/Pre.tsx +2 -1
  214. package/src/theme/MDXComponents/index.tsx +2 -0
  215. package/src/theme/MDXPage/index.tsx +6 -4
  216. package/src/theme/Navbar/Content/index.tsx +2 -2
  217. package/src/theme/Navbar/Layout/index.tsx +2 -2
  218. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +2 -2
  219. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +1 -1
  220. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +2 -1
  221. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +2 -1
  222. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +2 -2
  223. package/src/theme/Navbar/MobileSidebar/index.tsx +1 -1
  224. package/src/theme/NavbarItem/DocNavbarItem.tsx +1 -1
  225. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +1 -1
  226. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -4
  227. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +1 -1
  228. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +2 -3
  229. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -2
  230. package/src/theme/NavbarItem/NavbarNavLink.tsx +1 -1
  231. package/src/theme/NavbarItem/index.tsx +1 -1
  232. package/src/theme/SiteMetadata/index.tsx +2 -3
  233. package/src/theme/SkipToContent/index.tsx +1 -1
  234. package/src/theme/TOCItems/index.tsx +3 -3
  235. package/src/theme/Tabs/index.tsx +2 -2
  236. package/src/theme-classic.d.ts +128 -36
  237. package/src/validateThemeConfig.ts +14 -18
  238. package/lib/theme/LayoutProviders/index.d.ts +0 -9
  239. package/lib/theme/LayoutProviders/index.js +0 -33
  240. package/src/theme/LayoutProviders/index.tsx +0 -36
@@ -15,9 +15,9 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  import Link from '@docusaurus/Link';
17
17
  import BlogLayout from '@theme/BlogLayout';
18
- import BlogPostItem from '@theme/BlogPostItem';
19
18
  import BlogListPaginator from '@theme/BlogListPaginator';
20
19
  import SearchMetadata from '@theme/SearchMetadata';
20
+ import BlogPostItems from '@theme/BlogPostItems';
21
21
  // Very simple pluralization: probably good enough for now
22
22
  function useBlogPostsPlural() {
23
23
  const {selectMessage} = usePluralForm();
@@ -35,9 +35,9 @@ function useBlogPostsPlural() {
35
35
  ),
36
36
  );
37
37
  }
38
- export default function BlogTagsPostsPage({tag, items, sidebar, listMetadata}) {
38
+ function useBlogTagsPostsPageTitle(tag) {
39
39
  const blogPostsPlural = useBlogPostsPlural();
40
- const title = translate(
40
+ return translate(
41
41
  {
42
42
  id: 'theme.blog.tagTitle',
43
43
  description: 'The title of the page for a blog tag',
@@ -45,39 +45,45 @@ export default function BlogTagsPostsPage({tag, items, sidebar, listMetadata}) {
45
45
  },
46
46
  {nPosts: blogPostsPlural(tag.count), tagName: tag.label},
47
47
  );
48
+ }
49
+ function BlogTagsPostsPageMetadata({tag}) {
50
+ const title = useBlogTagsPostsPageTitle(tag);
51
+ return (
52
+ <>
53
+ <PageMetadata title={title} />
54
+ <SearchMetadata tag="blog_tags_posts" />
55
+ </>
56
+ );
57
+ }
58
+ function BlogTagsPostsPageContent({tag, items, sidebar, listMetadata}) {
59
+ const title = useBlogTagsPostsPageTitle(tag);
60
+ return (
61
+ <BlogLayout sidebar={sidebar}>
62
+ <header className="margin-bottom--xl">
63
+ <h1>{title}</h1>
64
+
65
+ <Link href={tag.allTagsPath}>
66
+ <Translate
67
+ id="theme.tags.tagsPageLink"
68
+ description="The label of the link targeting the tag list page">
69
+ View All Tags
70
+ </Translate>
71
+ </Link>
72
+ </header>
73
+ <BlogPostItems items={items} />
74
+ <BlogListPaginator metadata={listMetadata} />
75
+ </BlogLayout>
76
+ );
77
+ }
78
+ export default function BlogTagsPostsPage(props) {
48
79
  return (
49
80
  <HtmlClassNameProvider
50
81
  className={clsx(
51
82
  ThemeClassNames.wrapper.blogPages,
52
83
  ThemeClassNames.page.blogTagPostListPage,
53
84
  )}>
54
- <PageMetadata title={title} />
55
- <SearchMetadata tag="blog_tags_posts" />
56
- <BlogLayout sidebar={sidebar}>
57
- <header className="margin-bottom--xl">
58
- <h1>{title}</h1>
59
-
60
- <Link href={tag.allTagsPath}>
61
- <Translate
62
- id="theme.tags.tagsPageLink"
63
- description="The label of the link targeting the tag list page">
64
- View All Tags
65
- </Translate>
66
- </Link>
67
- </header>
68
-
69
- {items.map(({content: BlogPostContent}) => (
70
- <BlogPostItem
71
- key={BlogPostContent.metadata.permalink}
72
- frontMatter={BlogPostContent.frontMatter}
73
- assets={BlogPostContent.assets}
74
- metadata={BlogPostContent.metadata}
75
- truncated>
76
- <BlogPostContent />
77
- </BlogPostItem>
78
- ))}
79
- <BlogListPaginator metadata={listMetadata} />
80
- </BlogLayout>
85
+ <BlogTagsPostsPageMetadata {...props} />
86
+ <BlogTagsPostsPageContent {...props} />
81
87
  </HtmlClassNameProvider>
82
88
  );
83
89
  }
@@ -6,11 +6,8 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {
10
- usePrismTheme,
11
- getPrismCssVariables,
12
- ThemeClassNames,
13
- } from '@docusaurus/theme-common';
9
+ import {ThemeClassNames, usePrismTheme} from '@docusaurus/theme-common';
10
+ import {getPrismCssVariables} from '@docusaurus/theme-common/internal';
14
11
  import styles from './styles.module.css';
15
12
  export default function CodeBlockContainer({as: As, ...props}) {
16
13
  const prismTheme = usePrismTheme();
@@ -6,15 +6,14 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
+ import {useThemeConfig, usePrismTheme} from '@docusaurus/theme-common';
9
10
  import {
10
- useThemeConfig,
11
11
  parseCodeBlockTitle,
12
12
  parseLanguage,
13
13
  parseLines,
14
14
  containsLineNumbers,
15
- usePrismTheme,
16
15
  useCodeWordWrap,
17
- } from '@docusaurus/theme-common';
16
+ } from '@docusaurus/theme-common/internal';
18
17
  import Highlight, {defaultProps} from 'prism-react-renderer';
19
18
  import Line from '@theme/CodeBlock/Line';
20
19
  import CopyButton from '@theme/CodeBlock/CopyButton';
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import React, {useCallback, useState, useRef, useEffect} from 'react';
8
8
  import clsx from 'clsx';
9
+ // @ts-expect-error: TODO, we need to make theme-classic have type: module
9
10
  import copy from 'copy-text-to-clipboard';
10
11
  import {translate} from '@docusaurus/Translate';
11
12
  import styles from './styles.module.css';
@@ -5,13 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- :global(.theme-code-block-highlighted-line) {
9
- background-color: var(--docusaurus-highlighted-code-line-bg);
10
- display: block;
11
- margin: 0 calc(-1 * var(--ifm-pre-padding));
12
- padding: 0 var(--ifm-pre-padding);
13
- }
14
-
15
8
  /* Intentionally has zero specificity, so that to be able to override
16
9
  the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
17
10
  :where(:root) {
@@ -22,6 +15,13 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
22
15
  --docusaurus-highlighted-code-line-bg: rgb(100 100 100);
23
16
  }
24
17
 
18
+ :global(.theme-code-block-highlighted-line) {
19
+ background-color: var(--docusaurus-highlighted-code-line-bg);
20
+ display: block;
21
+ margin: 0 calc(-1 * var(--ifm-pre-padding));
22
+ padding: 0 var(--ifm-pre-padding);
23
+ }
24
+
25
25
  .codeLine {
26
26
  display: table-row;
27
27
  counter-increment: line-count;
@@ -8,8 +8,8 @@ import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import useIsBrowser from '@docusaurus/useIsBrowser';
10
10
  import {translate} from '@docusaurus/Translate';
11
- import IconLightMode from '@theme/IconLightMode';
12
- import IconDarkMode from '@theme/IconDarkMode';
11
+ import IconLightMode from '@theme/Icon/LightMode';
12
+ import IconDarkMode from '@theme/Icon/DarkMode';
13
13
  import styles from './styles.module.css';
14
14
  function ColorModeToggle({className, value, onChange}) {
15
15
  const isBrowser = useIsBrowser();
@@ -6,15 +6,15 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
+ import {ThemeClassNames} from '@docusaurus/theme-common';
9
10
  import {
10
- ThemeClassNames,
11
11
  useSidebarBreadcrumbs,
12
12
  useHomePageRoute,
13
- } from '@docusaurus/theme-common';
13
+ } from '@docusaurus/theme-common/internal';
14
14
  import Link from '@docusaurus/Link';
15
15
  import useBaseUrl from '@docusaurus/useBaseUrl';
16
16
  import {translate} from '@docusaurus/Translate';
17
- import IconHome from '@theme/IconHome';
17
+ import IconHome from '@theme/Icon/Home';
18
18
  import styles from './styles.module.css';
19
19
  // TODO move to design system folder
20
20
  function BreadcrumbsItemLink({children, href, isLast}) {
@@ -7,7 +7,10 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import Link from '@docusaurus/Link';
10
- import {findFirstCategoryLink, useDocById} from '@docusaurus/theme-common';
10
+ import {
11
+ findFirstCategoryLink,
12
+ useDocById,
13
+ } from '@docusaurus/theme-common/internal';
11
14
  import isInternalUrl from '@docusaurus/isInternalUrl';
12
15
  import {translate} from '@docusaurus/Translate';
13
16
  import styles from './styles.module.css';
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {findFirstCategoryLink} from '@docusaurus/theme-common';
9
+ import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
10
10
  import DocCard from '@theme/DocCard';
11
11
  // Filter categories that don't have a link.
12
12
  function filterItems(items) {
@@ -22,7 +22,7 @@ export default function DocCardList({items, className}) {
22
22
  <section className={clsx('row', className)}>
23
23
  {filterItems(items).map((item, index) => (
24
24
  <article key={index} className="col col--6 margin-bottom--lg">
25
- <DocCard key={index} item={item} />
25
+ <DocCard item={item} />
26
26
  </article>
27
27
  ))}
28
28
  </section>
@@ -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/DocItem/Content';
9
+ export default function DocItemContent({ children }: Props): JSX.Element;
@@ -0,0 +1,44 @@
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 {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
11
+ import Heading from '@theme/Heading';
12
+ import MDXContent from '@theme/MDXContent';
13
+ /**
14
+ Title can be declared inside md content or declared through
15
+ front matter and added manually. To make both cases consistent,
16
+ the added title is added under the same div.markdown block
17
+ See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
18
+
19
+ We render a "synthetic title" if:
20
+ - user doesn't ask to hide it with front matter
21
+ - the markdown content does not already contain a top-level h1 heading
22
+ */
23
+ function useSyntheticTitle() {
24
+ const {metadata, frontMatter, contentTitle} = useDoc();
25
+ const shouldRender =
26
+ !frontMatter.hide_title && typeof contentTitle === 'undefined';
27
+ if (!shouldRender) {
28
+ return null;
29
+ }
30
+ return metadata.title;
31
+ }
32
+ export default function DocItemContent({children}) {
33
+ const syntheticTitle = useSyntheticTitle();
34
+ return (
35
+ <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
36
+ {syntheticTitle && (
37
+ <header>
38
+ <Heading as="h1">{syntheticTitle}</Heading>
39
+ </header>
40
+ )}
41
+ <MDXContent>{children}</MDXContent>
42
+ </div>
43
+ );
44
+ }
@@ -0,0 +1,8 @@
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
+ export default function DocItemFooter(): JSX.Element | null;
@@ -7,6 +7,7 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
10
11
  import LastUpdated from '@theme/LastUpdated';
11
12
  import EditThisPage from '@theme/EditThisPage';
12
13
  import TagsListInline from '@theme/TagsListInline';
@@ -46,9 +47,8 @@ function EditMetaRow({
46
47
  </div>
47
48
  );
48
49
  }
49
- export default function DocItemFooter(props) {
50
- const {content: DocContent} = props;
51
- const {metadata} = DocContent;
50
+ export default function DocItemFooter() {
51
+ const {metadata} = useDoc();
52
52
  const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} =
53
53
  metadata;
54
54
  const canDisplayTagsRow = tags.length > 0;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="react" />
8
- import type { Props } from '@theme/BlogPostAuthor';
9
- export default function BlogPostAuthor({ author }: Props): JSX.Element;
8
+ import type { Props } from '@theme/DocItem/Layout';
9
+ export default function DocItemLayout({ children }: Props): JSX.Element;
@@ -0,0 +1,59 @@
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 {useWindowSize} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
11
+ import DocItemPaginator from '@theme/DocItem/Paginator';
12
+ import DocVersionBanner from '@theme/DocVersionBanner';
13
+ import DocVersionBadge from '@theme/DocVersionBadge';
14
+ import DocItemFooter from '@theme/DocItem/Footer';
15
+ import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
16
+ import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
17
+ import DocItemContent from '@theme/DocItem/Content';
18
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
19
+ import styles from './styles.module.css';
20
+ /**
21
+ * Decide if the toc should be rendered, on mobile or desktop viewports
22
+ */
23
+ function useDocTOC() {
24
+ const {frontMatter, toc} = useDoc();
25
+ const windowSize = useWindowSize();
26
+ const hidden = frontMatter.hide_table_of_contents;
27
+ const canRender = !hidden && toc.length > 0;
28
+ const mobile = canRender ? <DocItemTOCMobile /> : undefined;
29
+ const desktop =
30
+ canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? (
31
+ <DocItemTOCDesktop />
32
+ ) : undefined;
33
+ return {
34
+ hidden,
35
+ mobile,
36
+ desktop,
37
+ };
38
+ }
39
+ export default function DocItemLayout({children}) {
40
+ const docTOC = useDocTOC();
41
+ return (
42
+ <div className="row">
43
+ <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
44
+ <DocVersionBanner />
45
+ <div className={styles.docItemContainer}>
46
+ <article>
47
+ <DocBreadcrumbs />
48
+ <DocVersionBadge />
49
+ {docTOC.mobile}
50
+ <DocItemContent>{children}</DocItemContent>
51
+ <DocItemFooter />
52
+ </article>
53
+ <DocItemPaginator />
54
+ </div>
55
+ </div>
56
+ {docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
57
+ </div>
58
+ );
59
+ }
@@ -0,0 +1,17 @@
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
+ .docItemContainer header + *,
9
+ .docItemContainer article > *:first-child {
10
+ margin-top: 0;
11
+ }
12
+
13
+ @media (min-width: 997px) {
14
+ .docItemCol {
15
+ max-width: 75% !important;
16
+ }
17
+ }
@@ -0,0 +1,8 @@
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
+ export default function DocItemMetadata(): JSX.Element;
@@ -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
+ import React from 'react';
8
+ import {PageMetadata} from '@docusaurus/theme-common';
9
+ import {useDoc} from '@docusaurus/theme-common/internal';
10
+ export default function DocItemMetadata() {
11
+ const {metadata, frontMatter, assets} = useDoc();
12
+ return (
13
+ <PageMetadata
14
+ title={metadata.title}
15
+ description={metadata.description}
16
+ keywords={frontMatter.keywords}
17
+ image={assets.image ?? frontMatter.image}
18
+ />
19
+ );
20
+ }
@@ -4,7 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- /// <reference types="@docusaurus/plugin-content-docs" />
8
7
  /// <reference types="react" />
9
- import type { Props } from '@theme/DocItem';
10
- export default function DocItemFooter(props: Props): JSX.Element | null;
8
+ /**
9
+ * This extra component is needed, because <DocPaginator> should remain generic.
10
+ * DocPaginator is used in non-docs contexts too: generated-index pages...
11
+ */
12
+ export default function DocItemPaginator(): JSX.Element;
@@ -0,0 +1,17 @@
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 {useDoc} from '@docusaurus/theme-common/internal';
9
+ import DocPaginator from '@theme/DocPaginator';
10
+ /**
11
+ * This extra component is needed, because <DocPaginator> should remain generic.
12
+ * DocPaginator is used in non-docs contexts too: generated-index pages...
13
+ */
14
+ export default function DocItemPaginator() {
15
+ const {metadata} = useDoc();
16
+ return <DocPaginator previous={metadata.previous} next={metadata.next} />;
17
+ }
@@ -0,0 +1,8 @@
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
+ export default function DocItemTOCDesktop(): JSX.Element;
@@ -0,0 +1,21 @@
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 {ThemeClassNames} from '@docusaurus/theme-common';
9
+ import {useDoc} from '@docusaurus/theme-common/internal';
10
+ import TOC from '@theme/TOC';
11
+ export default function DocItemTOCDesktop() {
12
+ const {toc, frontMatter} = useDoc();
13
+ return (
14
+ <TOC
15
+ toc={toc}
16
+ minHeadingLevel={frontMatter.toc_min_heading_level}
17
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
18
+ className={ThemeClassNames.docs.docTocDesktop}
19
+ />
20
+ );
21
+ }
@@ -0,0 +1,8 @@
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
+ export default function DocItemTOCMobile(): JSX.Element;
@@ -0,0 +1,23 @@
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 {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import {useDoc} from '@docusaurus/theme-common/internal';
11
+ import TOCCollapsible from '@theme/TOCCollapsible';
12
+ import styles from './styles.module.css';
13
+ export default function DocItemTOCMobile() {
14
+ const {toc, frontMatter} = useDoc();
15
+ return (
16
+ <TOCCollapsible
17
+ toc={toc}
18
+ minHeadingLevel={frontMatter.toc_min_heading_level}
19
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
20
+ className={clsx(ThemeClassNames.docs.docTocMobile, styles.tocMobile)}
21
+ />
22
+ );
23
+ }
@@ -5,16 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docItemContainer header + *,
9
- .docItemContainer article > *:first-child {
10
- margin-top: 0;
11
- }
12
-
13
8
  @media (min-width: 997px) {
14
- .docItemCol {
15
- max-width: 75% !important;
16
- }
17
-
18
9
  /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
19
10
  .tocMobile {
20
11
  display: none;