@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
@@ -5,102 +5,205 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React from 'react';
8
+ import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import Translate from '@docusaurus/Translate';
10
12
  import type {Props} from '@theme/Admonition';
11
13
 
12
- const icons = {
13
- note: (
14
- <svg
15
- xmlns="http://www.w3.org/2000/svg"
16
- width="14"
17
- height="16"
18
- viewBox="0 0 14 16">
14
+ import styles from './styles.module.css';
15
+
16
+ function NoteIcon() {
17
+ return (
18
+ <svg viewBox="0 0 14 16">
19
19
  <path
20
20
  fillRule="evenodd"
21
21
  d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
22
22
  />
23
23
  </svg>
24
- ),
25
- tip: (
26
- <svg
27
- xmlns="http://www.w3.org/2000/svg"
28
- width="12"
29
- height="16"
30
- viewBox="0 0 12 16">
24
+ );
25
+ }
26
+
27
+ function TipIcon() {
28
+ return (
29
+ <svg viewBox="0 0 12 16">
31
30
  <path
32
31
  fillRule="evenodd"
33
32
  d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"
34
33
  />
35
34
  </svg>
36
- ),
37
- danger: (
38
- <svg
39
- xmlns="http://www.w3.org/2000/svg"
40
- width="12"
41
- height="16"
42
- viewBox="0 0 12 16">
35
+ );
36
+ }
37
+
38
+ function DangerIcon() {
39
+ return (
40
+ <svg viewBox="0 0 12 16">
43
41
  <path
44
42
  fillRule="evenodd"
45
43
  d="M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"
46
44
  />
47
45
  </svg>
48
- ),
49
- info: (
50
- <svg
51
- xmlns="http://www.w3.org/2000/svg"
52
- width="14"
53
- height="16"
54
- viewBox="0 0 14 16">
46
+ );
47
+ }
48
+
49
+ function InfoIcon() {
50
+ return (
51
+ <svg viewBox="0 0 14 16">
55
52
  <path
56
53
  fillRule="evenodd"
57
54
  d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"
58
55
  />
59
56
  </svg>
60
- ),
61
- caution: (
62
- <svg
63
- xmlns="http://www.w3.org/2000/svg"
64
- width="16"
65
- height="16"
66
- viewBox="0 0 16 16">
57
+ );
58
+ }
59
+
60
+ function CautionIcon() {
61
+ return (
62
+ <svg viewBox="0 0 16 16">
67
63
  <path
68
64
  fillRule="evenodd"
69
65
  d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"
70
66
  />
71
67
  </svg>
72
- ),
68
+ );
69
+ }
70
+
71
+ type AdmonitionConfig = {
72
+ iconComponent: React.ComponentType;
73
+ infimaClassName: string;
74
+ label: ReactNode;
73
75
  };
74
76
 
75
- const ifmClassNames = {
76
- note: 'secondary',
77
- tip: 'success',
78
- danger: 'danger',
79
- info: 'info',
80
- caution: 'warning',
77
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
78
+ const AdmonitionConfigs: Record<Props['type'], AdmonitionConfig> = {
79
+ note: {
80
+ infimaClassName: 'secondary',
81
+ iconComponent: NoteIcon,
82
+ label: (
83
+ <Translate
84
+ id="theme.admonition.note"
85
+ description="The default label used for the Note admonition (:::note)">
86
+ note
87
+ </Translate>
88
+ ),
89
+ },
90
+ tip: {
91
+ infimaClassName: 'success',
92
+ iconComponent: TipIcon,
93
+ label: (
94
+ <Translate
95
+ id="theme.admonition.tip"
96
+ description="The default label used for the Tip admonition (:::tip)">
97
+ tip
98
+ </Translate>
99
+ ),
100
+ },
101
+ danger: {
102
+ infimaClassName: 'danger',
103
+ iconComponent: DangerIcon,
104
+ label: (
105
+ <Translate
106
+ id="theme.admonition.danger"
107
+ description="The default label used for the Danger admonition (:::danger)">
108
+ danger
109
+ </Translate>
110
+ ),
111
+ },
112
+ info: {
113
+ infimaClassName: 'info',
114
+ iconComponent: InfoIcon,
115
+ label: (
116
+ <Translate
117
+ id="theme.admonition.info"
118
+ description="The default label used for the Info admonition (:::info)">
119
+ info
120
+ </Translate>
121
+ ),
122
+ },
123
+ caution: {
124
+ infimaClassName: 'warning',
125
+ iconComponent: CautionIcon,
126
+ label: (
127
+ <Translate
128
+ id="theme.admonition.caution"
129
+ description="The default label used for the Caution admonition (:::caution)">
130
+ caution
131
+ </Translate>
132
+ ),
133
+ },
81
134
  };
82
135
 
83
- export default function Admonition({
84
- children,
85
- type,
86
- title = type,
87
- icon = icons[type],
88
- }: Props): JSX.Element {
136
+ // Legacy aliases, undocumented but kept for retro-compatibility
137
+ const aliases = {
138
+ secondary: 'note',
139
+ important: 'info',
140
+ success: 'tip',
141
+ warning: 'danger',
142
+ } as const;
143
+
144
+ function getAdmonitionConfig(unsafeType: string): AdmonitionConfig {
145
+ const type =
146
+ (aliases as {[key: string]: Props['type']})[unsafeType] ?? unsafeType;
147
+ const config = (AdmonitionConfigs as {[key: string]: AdmonitionConfig})[type];
148
+ if (config) {
149
+ return config;
150
+ }
151
+ console.warn(
152
+ `No admonition config found for admonition type "${type}". Using Info as fallback.`,
153
+ );
154
+ return AdmonitionConfigs.info;
155
+ }
156
+
157
+ // Workaround because it's difficult in MDX v1 to provide a MDX title as props
158
+ // See https://github.com/facebook/docusaurus/pull/7152#issuecomment-1145779682
159
+ function extractMDXAdmonitionTitle(children: ReactNode): {
160
+ mdxAdmonitionTitle: ReactNode | undefined;
161
+ rest: ReactNode;
162
+ } {
163
+ const items = React.Children.toArray(children);
164
+ const mdxAdmonitionTitle = items.find(
165
+ (item) =>
166
+ React.isValidElement(item) &&
167
+ (item.props as {mdxType: string} | null)?.mdxType ===
168
+ 'mdxAdmonitionTitle',
169
+ );
170
+ const rest = <>{items.filter((item) => item !== mdxAdmonitionTitle)}</>;
171
+ return {
172
+ mdxAdmonitionTitle,
173
+ rest,
174
+ };
175
+ }
176
+
177
+ function processAdmonitionProps(props: Props): Props {
178
+ const {mdxAdmonitionTitle, rest} = extractMDXAdmonitionTitle(props.children);
179
+ return {
180
+ ...props,
181
+ title: props.title ?? mdxAdmonitionTitle,
182
+ children: rest,
183
+ };
184
+ }
185
+
186
+ export default function Admonition(props: Props): JSX.Element {
187
+ const {children, type, title, icon: iconProp} = processAdmonitionProps(props);
188
+
189
+ const typeConfig = getAdmonitionConfig(type);
190
+ const titleLabel = title ?? typeConfig.label;
191
+ const {iconComponent: IconComponent} = typeConfig;
192
+ const icon = iconProp ?? <IconComponent />;
89
193
  return (
90
194
  <div
91
195
  className={clsx(
92
- 'admonition',
93
- `admonition-${type}`,
196
+ ThemeClassNames.common.admonition,
197
+ ThemeClassNames.common.admonitionType(props.type),
94
198
  'alert',
95
- `alert--${ifmClassNames[type]}`,
199
+ `alert--${typeConfig.infimaClassName}`,
200
+ styles.admonition,
96
201
  )}>
97
- <div className="admonition-heading">
98
- <h5>
99
- <span className="admonition-icon">{icon}</span>
100
- {title}
101
- </h5>
202
+ <div className={styles.admonitionHeading}>
203
+ <span className={styles.admonitionIcon}>{icon}</span>
204
+ {titleLabel}
102
205
  </div>
103
- <div className="admonition-content">{children}</div>
206
+ <div className={styles.admonitionContent}>{children}</div>
104
207
  </div>
105
208
  );
106
209
  }
@@ -5,35 +5,34 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .admonition h5 {
9
- margin-top: 0;
10
- margin-bottom: 8px;
8
+ .admonition {
9
+ margin-bottom: 1em;
10
+ }
11
+
12
+ .admonitionHeading {
13
+ font: var(--ifm-heading-font-weight) var(--ifm-h5-font-size) /
14
+ var(--ifm-heading-line-height) var(--ifm-heading-font-family);
11
15
  text-transform: uppercase;
16
+ margin-bottom: 0.3rem;
12
17
  }
13
18
 
14
- .admonition h5 code {
19
+ .admonitionHeading code {
15
20
  text-transform: none;
16
21
  }
17
22
 
18
- .admonition-icon {
23
+ .admonitionIcon {
19
24
  display: inline-block;
20
25
  vertical-align: middle;
21
26
  margin-right: 0.4em;
22
27
  }
23
28
 
24
- .admonition-icon svg {
29
+ .admonitionIcon svg {
25
30
  display: inline-block;
26
- width: 22px;
27
- height: 22px;
28
- stroke-width: 0;
31
+ height: 1.6em;
32
+ width: 1.6em;
29
33
  fill: var(--ifm-alert-foreground-color);
30
- stroke: var(--ifm-alert-foreground-color);
31
34
  }
32
35
 
33
- .admonition-content > :last-child {
36
+ .admonitionContent > :last-child {
34
37
  margin-bottom: 0;
35
38
  }
36
-
37
- .admonition {
38
- margin-bottom: 1em;
39
- }
@@ -7,9 +7,10 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {useThemeConfig, useAnnouncementBar} from '@docusaurus/theme-common';
10
+ import {useThemeConfig} from '@docusaurus/theme-common';
11
+ import {useAnnouncementBar} from '@docusaurus/theme-common/internal';
11
12
  import {translate} from '@docusaurus/Translate';
12
- import IconClose from '@theme/IconClose';
13
+ import IconClose from '@theme/Icon/Close';
13
14
 
14
15
  import styles from './styles.module.css';
15
16
 
@@ -8,7 +8,8 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {translate} from '@docusaurus/Translate';
11
- import {ThemeClassNames, useBackToTopButton} from '@docusaurus/theme-common';
11
+ import {ThemeClassNames} from '@docusaurus/theme-common';
12
+ import {useBackToTopButton} from '@docusaurus/theme-common/internal';
12
13
 
13
14
  import styles from './styles.module.css';
14
15
 
@@ -15,10 +15,10 @@ import {
15
15
  ThemeClassNames,
16
16
  } from '@docusaurus/theme-common';
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';
21
20
  import type {Props} from '@theme/BlogListPage';
21
+ import BlogPostItems from '@theme/BlogPostItems';
22
22
 
23
23
  function BlogListPageMetadata(props: Props): JSX.Element {
24
24
  const {metadata} = props;
@@ -40,16 +40,7 @@ function BlogListPageContent(props: Props): JSX.Element {
40
40
  const {metadata, items, sidebar} = props;
41
41
  return (
42
42
  <BlogLayout sidebar={sidebar}>
43
- {items.map(({content: BlogPostContent}) => (
44
- <BlogPostItem
45
- key={BlogPostContent.metadata.permalink}
46
- frontMatter={BlogPostContent.frontMatter}
47
- assets={BlogPostContent.assets}
48
- metadata={BlogPostContent.metadata}
49
- truncated={BlogPostContent.metadata.truncated}>
50
- <BlogPostContent />
51
- </BlogPostItem>
52
- ))}
43
+ <BlogPostItems items={items} />
53
44
  <BlogListPaginator metadata={metadata} />
54
45
  </BlogLayout>
55
46
  );
@@ -0,0 +1,32 @@
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 {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
10
+ import {useBlogPost} from '@docusaurus/theme-common/internal';
11
+ import type {Props} from '@theme/BlogPostItem/Container';
12
+
13
+ export default function BlogPostItemContainer({
14
+ children,
15
+ className,
16
+ }: Props): JSX.Element {
17
+ const {frontMatter, assets} = useBlogPost();
18
+ const {withBaseUrl} = useBaseUrlUtils();
19
+ const image = assets.image ?? frontMatter.image;
20
+ return (
21
+ <article
22
+ className={className}
23
+ itemProp="blogPost"
24
+ itemScope
25
+ itemType="http://schema.org/BlogPosting">
26
+ {image && (
27
+ <meta itemProp="image" content={withBaseUrl(image, {absolute: true})} />
28
+ )}
29
+ {children}
30
+ </article>
31
+ );
32
+ }
@@ -0,0 +1,29 @@
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 {blogPostContainerID} from '@docusaurus/utils-common';
11
+ import {useBlogPost} from '@docusaurus/theme-common/internal';
12
+ import MDXContent from '@theme/MDXContent';
13
+ import type {Props} from '@theme/BlogPostItem/Content';
14
+
15
+ export default function BlogPostItemContent({
16
+ children,
17
+ className,
18
+ }: Props): JSX.Element {
19
+ const {isBlogPostPage} = useBlogPost();
20
+ return (
21
+ <div
22
+ // This ID is used for the feed generation to locate the main content
23
+ id={isBlogPostPage ? blogPostContainerID : undefined}
24
+ className={clsx('markdown', className)}
25
+ itemProp="articleBody">
26
+ <MDXContent>{children}</MDXContent>
27
+ </div>
28
+ );
29
+ }
@@ -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
+
8
+ import React from 'react';
9
+ import Translate, {translate} from '@docusaurus/Translate';
10
+ import Link from '@docusaurus/Link';
11
+ import type {Props} from '@theme/BlogPostItem/Footer/ReadMoreLink';
12
+
13
+ function ReadMoreLabel() {
14
+ return (
15
+ <b>
16
+ <Translate
17
+ id="theme.blog.post.readMore"
18
+ description="The label used in blog post item excerpts to link to full blog posts">
19
+ Read More
20
+ </Translate>
21
+ </b>
22
+ );
23
+ }
24
+
25
+ export default function BlogPostItemFooterReadMoreLink(
26
+ props: Props,
27
+ ): JSX.Element {
28
+ const {blogPostTitle, ...linkProps} = props;
29
+ return (
30
+ <Link
31
+ aria-label={translate(
32
+ {
33
+ message: 'Read more about {title}',
34
+ id: 'theme.blog.post.readMoreLabel',
35
+ description:
36
+ 'The ARIA label for the link to full blog posts from excerpts',
37
+ },
38
+ {title: blogPostTitle},
39
+ )}
40
+ {...linkProps}>
41
+ <ReadMoreLabel />
42
+ </Link>
43
+ );
44
+ }
@@ -0,0 +1,60 @@
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 {useBlogPost} from '@docusaurus/theme-common/internal';
11
+ import EditThisPage from '@theme/EditThisPage';
12
+ import TagsListInline from '@theme/TagsListInline';
13
+ import ReadMoreLink from '@theme/BlogPostItem/Footer/ReadMoreLink';
14
+
15
+ import styles from './styles.module.css';
16
+
17
+ export default function BlogPostItemFooter(): JSX.Element | null {
18
+ const {metadata, isBlogPostPage} = useBlogPost();
19
+ const {tags, title, editUrl, hasTruncateMarker} = metadata;
20
+
21
+ // A post is truncated if it's in the "list view" and it has a truncate marker
22
+ const truncatedPost = !isBlogPostPage && hasTruncateMarker;
23
+
24
+ const tagsExists = tags.length > 0;
25
+
26
+ const renderFooter = tagsExists || truncatedPost || editUrl;
27
+
28
+ if (!renderFooter) {
29
+ return null;
30
+ }
31
+
32
+ return (
33
+ <footer
34
+ className={clsx(
35
+ 'row docusaurus-mt-lg',
36
+ isBlogPostPage && styles.blogPostFooterDetailsFull,
37
+ )}>
38
+ {tagsExists && (
39
+ <div className={clsx('col', {'col--9': truncatedPost})}>
40
+ <TagsListInline tags={tags} />
41
+ </div>
42
+ )}
43
+
44
+ {isBlogPostPage && editUrl && (
45
+ <div className="col margin-top--sm">
46
+ <EditThisPage editUrl={editUrl} />
47
+ </div>
48
+ )}
49
+
50
+ {truncatedPost && (
51
+ <div
52
+ className={clsx('col text--right', {
53
+ 'col--3': tagsExists,
54
+ })}>
55
+ <ReadMoreLink blogPostTitle={title} to={metadata.permalink} />
56
+ </div>
57
+ )}
58
+ </footer>
59
+ );
60
+ }
@@ -0,0 +1,10 @@
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
+ .blogPostFooterDetailsFull {
9
+ flex-direction: column;
10
+ }
@@ -6,8 +6,10 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import clsx from 'clsx';
9
10
  import Link, {type Props as LinkProps} from '@docusaurus/Link';
10
- import type {Props} from '@theme/BlogPostAuthor';
11
+
12
+ import type {Props} from '@theme/BlogPostItem/Header/Author';
11
13
 
12
14
  function MaybeLink(props: LinkProps): JSX.Element {
13
15
  if (props.href) {
@@ -16,11 +18,14 @@ function MaybeLink(props: LinkProps): JSX.Element {
16
18
  return <>{props.children}</>;
17
19
  }
18
20
 
19
- export default function BlogPostAuthor({author}: Props): JSX.Element {
21
+ export default function BlogPostItemHeaderAuthor({
22
+ author,
23
+ className,
24
+ }: Props): JSX.Element {
20
25
  const {name, title, url, imageURL, email} = author;
21
26
  const link = url || (email && `mailto:${email}`) || undefined;
22
27
  return (
23
- <div className="avatar margin-bottom--sm">
28
+ <div className={clsx('avatar margin-bottom--sm', className)}>
24
29
  {imageURL && (
25
30
  <MaybeLink href={link} className="avatar__photo-link">
26
31
  <img className="avatar__photo" src={imageURL} alt={name} />
@@ -4,12 +4,22 @@
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
+
7
8
  import React from 'react';
8
9
  import clsx from 'clsx';
9
- import BlogPostAuthor from '@theme/BlogPostAuthor';
10
+ import {useBlogPost} from '@docusaurus/theme-common/internal';
11
+ import BlogPostItemHeaderAuthor from '@theme/BlogPostItem/Header/Author';
12
+ import type {Props} from '@theme/BlogPostItem/Header/Authors';
10
13
  import styles from './styles.module.css';
14
+
11
15
  // Component responsible for the authors layout
12
- export default function BlogPostAuthors({authors, assets}) {
16
+ export default function BlogPostItemHeaderAuthors({
17
+ className,
18
+ }: Props): JSX.Element | null {
19
+ const {
20
+ metadata: {authors},
21
+ assets,
22
+ } = useBlogPost();
13
23
  const authorsCount = authors.length;
14
24
  if (authorsCount === 0) {
15
25
  return null;
@@ -20,6 +30,7 @@ export default function BlogPostAuthors({authors, assets}) {
20
30
  className={clsx(
21
31
  'margin-top--md margin-bottom--sm',
22
32
  imageOnly ? styles.imageOnlyAuthorRow : 'row',
33
+ className,
23
34
  )}>
24
35
  {authors.map((author, idx) => (
25
36
  <div
@@ -28,7 +39,7 @@ export default function BlogPostAuthors({authors, assets}) {
28
39
  imageOnly ? styles.imageOnlyAuthorCol : styles.authorCol,
29
40
  )}
30
41
  key={idx}>
31
- <BlogPostAuthor
42
+ <BlogPostItemHeaderAuthor
32
43
  author={{
33
44
  ...author,
34
45
  // Handle author images using relative paths