@docusaurus/theme-classic 2.4.1 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/lib/getSwizzleConfig.js +107 -8
  2. package/lib/index.js +20 -6
  3. package/lib/nprogress.d.ts +1 -1
  4. package/lib/options.js +6 -2
  5. package/lib/theme/Admonition/Icon/Danger.d.ts +9 -0
  6. package/lib/theme/Admonition/Icon/Danger.js +17 -0
  7. package/lib/theme/Admonition/Icon/Info.d.ts +9 -0
  8. package/lib/theme/Admonition/Icon/Info.js +17 -0
  9. package/lib/theme/Admonition/Icon/Note.d.ts +9 -0
  10. package/lib/theme/Admonition/Icon/Note.js +17 -0
  11. package/lib/theme/Admonition/Icon/Tip.d.ts +9 -0
  12. package/lib/theme/Admonition/Icon/Tip.js +17 -0
  13. package/lib/theme/Admonition/Icon/Warning.d.ts +9 -0
  14. package/lib/theme/Admonition/Icon/Warning.js +17 -0
  15. package/lib/theme/Admonition/Layout/index.d.ts +9 -0
  16. package/lib/theme/Admonition/Layout/index.js +45 -0
  17. package/lib/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  18. package/lib/theme/Admonition/Type/Caution.d.ts +9 -0
  19. package/lib/theme/Admonition/Type/Caution.js +34 -0
  20. package/lib/theme/Admonition/Type/Danger.d.ts +9 -0
  21. package/lib/theme/Admonition/Type/Danger.js +32 -0
  22. package/lib/theme/Admonition/Type/Info.d.ts +9 -0
  23. package/lib/theme/Admonition/Type/Info.js +32 -0
  24. package/lib/theme/Admonition/Type/Note.d.ts +9 -0
  25. package/lib/theme/Admonition/Type/Note.js +32 -0
  26. package/lib/theme/Admonition/Type/Tip.d.ts +9 -0
  27. package/lib/theme/Admonition/Type/Tip.js +32 -0
  28. package/lib/theme/Admonition/Type/Warning.d.ts +9 -0
  29. package/lib/theme/Admonition/Type/Warning.js +32 -0
  30. package/lib/theme/Admonition/Types.d.ts +12 -0
  31. package/lib/theme/Admonition/Types.js +33 -0
  32. package/lib/theme/Admonition/index.d.ts +1 -1
  33. package/lib/theme/Admonition/index.js +12 -171
  34. package/lib/theme/BlogArchivePage/index.js +7 -2
  35. package/lib/theme/BlogLayout/index.js +1 -1
  36. package/lib/theme/BlogPostItem/Container/index.js +12 -3
  37. package/lib/theme/BlogPostItem/Header/Author/index.js +6 -1
  38. package/lib/theme/BlogPostPage/index.js +3 -1
  39. package/lib/theme/BlogSidebar/Desktop/index.js +3 -1
  40. package/lib/theme/BlogSidebar/Mobile/index.js +3 -1
  41. package/lib/theme/BlogTagsListPage/index.js +2 -1
  42. package/lib/theme/BlogTagsPostsPage/index.js +4 -2
  43. package/lib/theme/CodeBlock/Content/String.js +9 -2
  44. package/lib/theme/CodeBlock/CopyButton/index.js +0 -1
  45. package/lib/theme/DocBreadcrumbs/index.js +6 -2
  46. package/lib/theme/DocCard/index.js +8 -4
  47. package/lib/theme/DocItem/Layout/index.js +5 -0
  48. package/lib/theme/DocItem/index.js +1 -1
  49. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.d.ts +2 -2
  50. package/lib/theme/{DocPage → DocRoot}/Layout/Main/index.js +1 -1
  51. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.d.ts +2 -2
  52. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.js +1 -1
  53. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.d.ts +2 -2
  54. package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/index.js +2 -2
  55. package/lib/theme/{DocPage → DocRoot}/Layout/index.d.ts +2 -2
  56. package/lib/theme/{DocPage → DocRoot}/Layout/index.js +9 -10
  57. package/lib/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  58. package/lib/theme/{DocPage → DocRoot}/index.d.ts +2 -2
  59. package/lib/theme/DocRoot/index.js +31 -0
  60. package/lib/theme/DocSidebar/Desktop/index.d.ts +1 -1
  61. package/lib/theme/DocSidebar/Mobile/index.d.ts +1 -1
  62. package/lib/theme/DocSidebarItem/Category/index.js +24 -13
  63. package/lib/theme/DocSidebarItems/index.js +6 -4
  64. package/lib/theme/DocTagDocListPage/index.d.ts +1 -1
  65. package/lib/theme/DocTagDocListPage/index.js +53 -39
  66. package/lib/theme/DocTagsListPage/index.d.ts +1 -1
  67. package/lib/theme/DocTagsListPage/index.js +26 -17
  68. package/lib/theme/DocVersionRoot/index.d.ts +10 -0
  69. package/lib/theme/DocVersionRoot/index.js +46 -0
  70. package/lib/theme/DocsRoot/index.d.ts +10 -0
  71. package/lib/theme/DocsRoot/index.js +18 -0
  72. package/lib/theme/EditThisPage/index.js +3 -6
  73. package/lib/theme/ErrorPageContent.js +3 -2
  74. package/lib/theme/MDXComponents/Code.js +2 -36
  75. package/lib/theme/MDXComponents/Details.js +1 -1
  76. package/lib/theme/MDXComponents/Pre.d.ts +2 -2
  77. package/lib/theme/MDXComponents/Pre.js +4 -11
  78. package/lib/theme/MDXComponents/Ul/index.js +4 -0
  79. package/lib/theme/MDXComponents/index.js +4 -3
  80. package/lib/theme/MDXPage/index.js +16 -4
  81. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -3
  82. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +1 -1
  83. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +2 -1
  84. package/lib/theme/NotFound/Content/index.d.ts +9 -0
  85. package/lib/theme/NotFound/Content/index.js +42 -0
  86. package/lib/theme/{NotFound.d.ts → NotFound/index.d.ts} +1 -1
  87. package/lib/theme/NotFound/index.js +25 -0
  88. package/lib/theme/SiteMetadata/index.js +30 -3
  89. package/lib/theme/TOCItems/Tree.js +3 -4
  90. package/lib/theme/Tabs/index.js +4 -2
  91. package/lib/theme/TagsListByLetter/index.js +4 -1
  92. package/lib/theme/ThemedImage/index.js +8 -24
  93. package/lib/theme/{MDXComponents/Head.d.ts → Unlisted/index.d.ts} +2 -2
  94. package/lib/theme/Unlisted/index.js +38 -0
  95. package/package.json +26 -26
  96. package/src/getSwizzleConfig.ts +116 -9
  97. package/src/index.ts +21 -6
  98. package/src/nprogress.ts +2 -1
  99. package/src/options.ts +7 -2
  100. package/src/theme/Admonition/Icon/Danger.tsx +20 -0
  101. package/src/theme/Admonition/Icon/Info.tsx +20 -0
  102. package/src/theme/Admonition/Icon/Note.tsx +20 -0
  103. package/src/theme/Admonition/Icon/Tip.tsx +20 -0
  104. package/src/theme/Admonition/Icon/Warning.tsx +20 -0
  105. package/src/theme/Admonition/Layout/index.tsx +57 -0
  106. package/src/theme/Admonition/{styles.module.css → Layout/styles.module.css} +4 -0
  107. package/src/theme/Admonition/Type/Caution.tsx +39 -0
  108. package/src/theme/Admonition/Type/Danger.tsx +37 -0
  109. package/src/theme/Admonition/Type/Info.tsx +37 -0
  110. package/src/theme/Admonition/Type/Note.tsx +37 -0
  111. package/src/theme/Admonition/Type/Tip.tsx +37 -0
  112. package/src/theme/Admonition/Type/Warning.tsx +37 -0
  113. package/src/theme/Admonition/Types.tsx +38 -0
  114. package/src/theme/Admonition/index.tsx +13 -194
  115. package/src/theme/BlogArchivePage/index.tsx +7 -2
  116. package/src/theme/BlogLayout/index.tsx +1 -1
  117. package/src/theme/BlogPostItem/Container/index.tsx +12 -3
  118. package/src/theme/BlogPostItem/Header/Author/index.tsx +6 -1
  119. package/src/theme/BlogPostPage/index.tsx +3 -1
  120. package/src/theme/BlogSidebar/Desktop/index.tsx +3 -1
  121. package/src/theme/BlogSidebar/Mobile/index.tsx +3 -1
  122. package/src/theme/BlogTagsListPage/index.tsx +2 -1
  123. package/src/theme/BlogTagsPostsPage/index.tsx +4 -2
  124. package/src/theme/CodeBlock/Content/String.tsx +11 -2
  125. package/src/theme/CodeBlock/CopyButton/index.tsx +0 -1
  126. package/src/theme/DocBreadcrumbs/index.tsx +6 -2
  127. package/src/theme/DocCard/index.tsx +11 -6
  128. package/src/theme/DocItem/Layout/index.tsx +5 -0
  129. package/src/theme/DocItem/index.tsx +1 -1
  130. package/src/theme/{DocPage → DocRoot}/Layout/Main/index.tsx +2 -2
  131. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/index.tsx +2 -2
  132. package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/index.tsx +3 -3
  133. package/src/theme/{DocPage → DocRoot}/Layout/index.tsx +10 -11
  134. package/src/theme/{DocPage → DocRoot}/Layout/styles.module.css +1 -2
  135. package/src/theme/DocRoot/index.tsx +34 -0
  136. package/src/theme/DocSidebarItem/Category/index.tsx +25 -12
  137. package/src/theme/DocSidebarItems/index.tsx +6 -4
  138. package/src/theme/DocTagDocListPage/index.tsx +60 -39
  139. package/src/theme/DocTagsListPage/index.tsx +33 -17
  140. package/src/theme/DocVersionRoot/index.tsx +51 -0
  141. package/src/theme/DocsRoot/index.tsx +22 -0
  142. package/src/theme/EditThisPage/index.tsx +3 -6
  143. package/src/theme/ErrorPageContent.tsx +3 -2
  144. package/src/theme/MDXComponents/Code.tsx +2 -39
  145. package/src/theme/MDXComponents/Details.tsx +1 -2
  146. package/src/theme/MDXComponents/Pre.tsx +5 -13
  147. package/src/theme/MDXComponents/Ul/index.tsx +5 -1
  148. package/src/theme/MDXComponents/index.tsx +11 -10
  149. package/src/theme/MDXPage/index.tsx +16 -4
  150. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -3
  151. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +2 -1
  152. package/src/theme/NotFound/Content/index.tsx +45 -0
  153. package/src/theme/NotFound/index.tsx +27 -0
  154. package/src/theme/SiteMetadata/index.tsx +36 -3
  155. package/src/theme/SkipToContent/index.tsx +0 -1
  156. package/src/theme/TOCItems/Tree.tsx +3 -4
  157. package/src/theme/Tabs/index.tsx +4 -2
  158. package/src/theme/TagsListByLetter/index.tsx +4 -2
  159. package/src/theme/ThemedImage/index.tsx +8 -31
  160. package/src/theme/Unlisted/index.tsx +42 -0
  161. package/src/theme/prism-include-languages.ts +2 -1
  162. package/src/theme-classic.d.ts +146 -21
  163. package/lib/theme/DocPage/index.js +0 -67
  164. package/lib/theme/MDXComponents/Head.js +0 -23
  165. package/lib/theme/NotFound.js +0 -52
  166. package/src/theme/DocPage/index.tsx +0 -71
  167. package/src/theme/MDXComponents/Head.tsx +0 -29
  168. package/src/theme/NotFound.tsx +0 -54
  169. /package/lib/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  170. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  171. /package/lib/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
  172. /package/src/theme/{DocPage → DocRoot}/Layout/Main/styles.module.css +0 -0
  173. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/ExpandButton/styles.module.css +0 -0
  174. /package/src/theme/{DocPage → DocRoot}/Layout/Sidebar/styles.module.css +0 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import AdmonitionTypeNote from '@theme/Admonition/Type/Note';
10
+ import AdmonitionTypeTip from '@theme/Admonition/Type/Tip';
11
+ import AdmonitionTypeInfo from '@theme/Admonition/Type/Info';
12
+ import AdmonitionTypeWarning from '@theme/Admonition/Type/Warning';
13
+ import AdmonitionTypeDanger from '@theme/Admonition/Type/Danger';
14
+ import AdmonitionTypeCaution from '@theme/Admonition/Type/Caution';
15
+ import type AdmonitionTypes from '@theme/Admonition/Types';
16
+
17
+ const admonitionTypes: typeof AdmonitionTypes = {
18
+ note: AdmonitionTypeNote,
19
+ tip: AdmonitionTypeTip,
20
+ info: AdmonitionTypeInfo,
21
+ warning: AdmonitionTypeWarning,
22
+ danger: AdmonitionTypeDanger,
23
+ };
24
+
25
+ // Undocumented legacy admonition type aliases
26
+ // Provide hardcoded/untranslated retrocompatible label
27
+ // See also https://github.com/facebook/docusaurus/issues/7767
28
+ const admonitionAliases: typeof AdmonitionTypes = {
29
+ secondary: (props) => <AdmonitionTypeNote title="secondary" {...props} />,
30
+ important: (props) => <AdmonitionTypeInfo title="important" {...props} />,
31
+ success: (props) => <AdmonitionTypeTip title="success" {...props} />,
32
+ caution: AdmonitionTypeCaution,
33
+ };
34
+
35
+ export default {
36
+ ...admonitionTypes,
37
+ ...admonitionAliases,
38
+ };
@@ -5,205 +5,24 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {type ReactNode} from 'react';
9
- import clsx from 'clsx';
10
- import {ThemeClassNames} from '@docusaurus/theme-common';
11
- import Translate from '@docusaurus/Translate';
8
+ import React, {type ComponentType} from 'react';
9
+ import {processAdmonitionProps} from '@docusaurus/theme-common';
12
10
  import type {Props} from '@theme/Admonition';
11
+ import AdmonitionTypes from '@theme/Admonition/Types';
13
12
 
14
- import styles from './styles.module.css';
15
-
16
- function NoteIcon() {
17
- return (
18
- <svg viewBox="0 0 14 16">
19
- <path
20
- fillRule="evenodd"
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
- />
23
- </svg>
24
- );
25
- }
26
-
27
- function TipIcon() {
28
- return (
29
- <svg viewBox="0 0 12 16">
30
- <path
31
- fillRule="evenodd"
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"
33
- />
34
- </svg>
35
- );
36
- }
37
-
38
- function DangerIcon() {
39
- return (
40
- <svg viewBox="0 0 12 16">
41
- <path
42
- fillRule="evenodd"
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"
44
- />
45
- </svg>
46
- );
47
- }
48
-
49
- function InfoIcon() {
50
- return (
51
- <svg viewBox="0 0 14 16">
52
- <path
53
- fillRule="evenodd"
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"
55
- />
56
- </svg>
57
- );
58
- }
59
-
60
- function CautionIcon() {
61
- return (
62
- <svg viewBox="0 0 16 16">
63
- <path
64
- fillRule="evenodd"
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"
66
- />
67
- </svg>
68
- );
69
- }
70
-
71
- type AdmonitionConfig = {
72
- iconComponent: React.ComponentType;
73
- infimaClassName: string;
74
- label: ReactNode;
75
- };
76
-
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
- },
134
- };
135
-
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;
13
+ function getAdmonitionTypeComponent(type: string): ComponentType<Props> {
14
+ const component = AdmonitionTypes[type];
15
+ if (component) {
16
+ return component;
150
17
  }
151
18
  console.warn(
152
- `No admonition config found for admonition type "${type}". Using Info as fallback.`,
19
+ `No admonition component found for admonition type "${type}". Using Info as fallback.`,
153
20
  );
154
- return AdmonitionConfigs.info;
21
+ return AdmonitionTypes.info!;
155
22
  }
156
23
 
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 />;
193
- return (
194
- <div
195
- className={clsx(
196
- ThemeClassNames.common.admonition,
197
- ThemeClassNames.common.admonitionType(props.type),
198
- 'alert',
199
- `alert--${typeConfig.infimaClassName}`,
200
- styles.admonition,
201
- )}>
202
- <div className={styles.admonitionHeading}>
203
- <span className={styles.admonitionIcon}>{icon}</span>
204
- {titleLabel}
205
- </div>
206
- <div className={styles.admonitionContent}>{children}</div>
207
- </div>
208
- );
24
+ export default function Admonition(unprocessedProps: Props): JSX.Element {
25
+ const props = processAdmonitionProps(unprocessedProps);
26
+ const AdmonitionTypeComponent = getAdmonitionTypeComponent(props.type);
27
+ return <AdmonitionTypeComponent {...props} />;
209
28
  }
@@ -11,6 +11,7 @@ import {translate} from '@docusaurus/Translate';
11
11
  import {PageMetadata} from '@docusaurus/theme-common';
12
12
  import Layout from '@theme/Layout';
13
13
  import type {ArchiveBlogPost, Props} from '@theme/BlogArchivePage';
14
+ import Heading from '@theme/Heading';
14
15
 
15
16
  type YearProp = {
16
17
  year: string;
@@ -20,7 +21,9 @@ type YearProp = {
20
21
  function Year({year, posts}: YearProp) {
21
22
  return (
22
23
  <>
23
- <h3>{year}</h3>
24
+ <Heading as="h3" id={year}>
25
+ {year}
26
+ </Heading>
24
27
  <ul>
25
28
  {posts.map((post) => (
26
29
  <li key={post.metadata.date}>
@@ -81,7 +84,9 @@ export default function BlogArchive({archive}: Props): JSX.Element {
81
84
  <Layout>
82
85
  <header className="hero hero--primary">
83
86
  <div className="container">
84
- <h1 className="hero__title">{title}</h1>
87
+ <Heading as="h1" className="hero__title">
88
+ {title}
89
+ </Heading>
85
90
  <p className="hero__subtitle">{description}</p>
86
91
  </div>
87
92
  </header>
@@ -27,7 +27,7 @@ export default function BlogLayout(props: Props): JSX.Element {
27
27
  'col--9 col--offset-1': !hasSidebar,
28
28
  })}
29
29
  itemScope
30
- itemType="http://schema.org/Blog">
30
+ itemType="https://schema.org/Blog">
31
31
  {children}
32
32
  </main>
33
33
  {toc && <div className="col col--2">{toc}</div>}
@@ -14,17 +14,26 @@ export default function BlogPostItemContainer({
14
14
  children,
15
15
  className,
16
16
  }: Props): JSX.Element {
17
- const {frontMatter, assets} = useBlogPost();
17
+ const {
18
+ frontMatter,
19
+ assets,
20
+ metadata: {description},
21
+ } = useBlogPost();
18
22
  const {withBaseUrl} = useBaseUrlUtils();
19
23
  const image = assets.image ?? frontMatter.image;
24
+ const keywords = frontMatter.keywords ?? [];
20
25
  return (
21
26
  <article
22
27
  className={className}
23
28
  itemProp="blogPost"
24
29
  itemScope
25
- itemType="http://schema.org/BlogPosting">
30
+ itemType="https://schema.org/BlogPosting">
31
+ {description && <meta itemProp="description" content={description} />}
26
32
  {image && (
27
- <meta itemProp="image" content={withBaseUrl(image, {absolute: true})} />
33
+ <link itemProp="image" href={withBaseUrl(image, {absolute: true})} />
34
+ )}
35
+ {keywords.length > 0 && (
36
+ <meta itemProp="keywords" content={keywords.join(',')} />
28
37
  )}
29
38
  {children}
30
39
  </article>
@@ -28,7 +28,12 @@ export default function BlogPostItemHeaderAuthor({
28
28
  <div className={clsx('avatar margin-bottom--sm', className)}>
29
29
  {imageURL && (
30
30
  <MaybeLink href={link} className="avatar__photo-link">
31
- <img className="avatar__photo" src={imageURL} alt={name} />
31
+ <img
32
+ className="avatar__photo"
33
+ src={imageURL}
34
+ alt={name}
35
+ itemProp="image"
36
+ />
32
37
  </MaybeLink>
33
38
  )}
34
39
 
@@ -15,6 +15,7 @@ import BlogPostPaginator from '@theme/BlogPostPaginator';
15
15
  import BlogPostPageMetadata from '@theme/BlogPostPage/Metadata';
16
16
  import TOC from '@theme/TOC';
17
17
  import type {Props} from '@theme/BlogPostPage';
18
+ import Unlisted from '@theme/Unlisted';
18
19
  import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
19
20
 
20
21
  function BlogPostPageContent({
@@ -25,7 +26,7 @@ function BlogPostPageContent({
25
26
  children: ReactNode;
26
27
  }): JSX.Element {
27
28
  const {metadata, toc} = useBlogPost();
28
- const {nextItem, prevItem, frontMatter} = metadata;
29
+ const {nextItem, prevItem, frontMatter, unlisted} = metadata;
29
30
  const {
30
31
  hide_table_of_contents: hideTableOfContents,
31
32
  toc_min_heading_level: tocMinHeadingLevel,
@@ -43,6 +44,7 @@ function BlogPostPageContent({
43
44
  />
44
45
  ) : undefined
45
46
  }>
47
+ {unlisted && <Unlisted />}
46
48
  <BlogPostItem>{children}</BlogPostItem>
47
49
 
48
50
  {(nextItem || prevItem) && (
@@ -9,11 +9,13 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Link from '@docusaurus/Link';
11
11
  import {translate} from '@docusaurus/Translate';
12
+ import {useVisibleBlogSidebarItems} from '@docusaurus/theme-common/internal';
12
13
  import type {Props} from '@theme/BlogSidebar/Desktop';
13
14
 
14
15
  import styles from './styles.module.css';
15
16
 
16
17
  export default function BlogSidebarDesktop({sidebar}: Props): JSX.Element {
18
+ const items = useVisibleBlogSidebarItems(sidebar.items);
17
19
  return (
18
20
  <aside className="col col--3">
19
21
  <nav
@@ -27,7 +29,7 @@ export default function BlogSidebarDesktop({sidebar}: Props): JSX.Element {
27
29
  {sidebar.title}
28
30
  </div>
29
31
  <ul className={clsx(styles.sidebarItemList, 'clean-list')}>
30
- {sidebar.items.map((item) => (
32
+ {items.map((item) => (
31
33
  <li key={item.permalink} className={styles.sidebarItem}>
32
34
  <Link
33
35
  isNavLink
@@ -7,13 +7,15 @@
7
7
 
8
8
  import React from 'react';
9
9
  import Link from '@docusaurus/Link';
10
+ import {useVisibleBlogSidebarItems} from '@docusaurus/theme-common/internal';
10
11
  import {NavbarSecondaryMenuFiller} from '@docusaurus/theme-common';
11
12
  import type {Props} from '@theme/BlogSidebar/Mobile';
12
13
 
13
14
  function BlogSidebarMobileSecondaryMenu({sidebar}: Props): JSX.Element {
15
+ const items = useVisibleBlogSidebarItems(sidebar.items);
14
16
  return (
15
17
  <ul className="menu__list">
16
- {sidebar.items.map((item) => (
18
+ {items.map((item) => (
17
19
  <li key={item.permalink} className="menu__list-item">
18
20
  <Link
19
21
  isNavLink
@@ -17,6 +17,7 @@ import BlogLayout from '@theme/BlogLayout';
17
17
  import TagsListByLetter from '@theme/TagsListByLetter';
18
18
  import type {Props} from '@theme/BlogTagsListPage';
19
19
  import SearchMetadata from '@theme/SearchMetadata';
20
+ import Heading from '@theme/Heading';
20
21
 
21
22
  export default function BlogTagsListPage({tags, sidebar}: Props): JSX.Element {
22
23
  const title = translateTagsPageTitle();
@@ -29,7 +30,7 @@ export default function BlogTagsListPage({tags, sidebar}: Props): JSX.Element {
29
30
  <PageMetadata title={title} />
30
31
  <SearchMetadata tag="blog_tags_list" />
31
32
  <BlogLayout sidebar={sidebar}>
32
- <h1>{title}</h1>
33
+ <Heading as="h1">{title}</Heading>
33
34
  <TagsListByLetter tags={tags} />
34
35
  </BlogLayout>
35
36
  </HtmlClassNameProvider>
@@ -20,6 +20,8 @@ import BlogListPaginator from '@theme/BlogListPaginator';
20
20
  import SearchMetadata from '@theme/SearchMetadata';
21
21
  import type {Props} from '@theme/BlogTagsPostsPage';
22
22
  import BlogPostItems from '@theme/BlogPostItems';
23
+ import Unlisted from '@theme/Unlisted';
24
+ import Heading from '@theme/Heading';
23
25
 
24
26
  // Very simple pluralization: probably good enough for now
25
27
  function useBlogPostsPlural() {
@@ -70,9 +72,9 @@ function BlogTagsPostsPageContent({
70
72
  const title = useBlogTagsPostsPageTitle(tag);
71
73
  return (
72
74
  <BlogLayout sidebar={sidebar}>
75
+ {tag.unlisted && <Unlisted />}
73
76
  <header className="margin-bottom--xl">
74
- <h1>{title}</h1>
75
-
77
+ <Heading as="h1">{title}</Heading>
76
78
  <Link href={tag.allTagsPath}>
77
79
  <Translate
78
80
  id="theme.tags.tagsPageLink"
@@ -24,6 +24,13 @@ import type {Props} from '@theme/CodeBlock/Content/String';
24
24
 
25
25
  import styles from './styles.module.css';
26
26
 
27
+ // Prism languages are always lowercase
28
+ // We want to fail-safe and allow both "php" and "PHP"
29
+ // See https://github.com/facebook/docusaurus/issues/9012
30
+ function normalizeLanguage(language: string | undefined): string | undefined {
31
+ return language?.toLowerCase();
32
+ }
33
+
27
34
  export default function CodeBlockString({
28
35
  children,
29
36
  className: blockClassName = '',
@@ -35,8 +42,10 @@ export default function CodeBlockString({
35
42
  const {
36
43
  prism: {defaultLanguage, magicComments},
37
44
  } = useThemeConfig();
38
- const language =
39
- languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
45
+ const language = normalizeLanguage(
46
+ languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage,
47
+ );
48
+
40
49
  const prismTheme = usePrismTheme();
41
50
  const wordWrap = useCodeWordWrap();
42
51
 
@@ -7,7 +7,6 @@
7
7
 
8
8
  import React, {useCallback, useState, useRef, useEffect} from 'react';
9
9
  import clsx from 'clsx';
10
- // @ts-expect-error: TODO, we need to make theme-classic have type: module
11
10
  import copy from 'copy-text-to-clipboard';
12
11
  import {translate} from '@docusaurus/Translate';
13
12
  import type {Props} from '@theme/CodeBlock/CopyButton';
@@ -104,13 +104,17 @@ export default function DocBreadcrumbs(): JSX.Element | null {
104
104
  {homePageRoute && <HomeBreadcrumbItem />}
105
105
  {breadcrumbs.map((item, idx) => {
106
106
  const isLast = idx === breadcrumbs.length - 1;
107
+ const href =
108
+ item.type === 'category' && item.linkUnlisted
109
+ ? undefined
110
+ : item.href;
107
111
  return (
108
112
  <BreadcrumbsItem
109
113
  key={idx}
110
114
  active={isLast}
111
115
  index={idx}
112
- addMicrodata={!!item.href}>
113
- <BreadcrumbsItemLink href={item.href} isLast={isLast}>
116
+ addMicrodata={!!href}>
117
+ <BreadcrumbsItemLink href={href} isLast={isLast}>
114
118
  {item.label}
115
119
  </BreadcrumbsItemLink>
116
120
  </BreadcrumbsItem>
@@ -9,19 +9,21 @@ import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import Link from '@docusaurus/Link';
11
11
  import {
12
- findFirstCategoryLink,
12
+ findFirstSidebarItemLink,
13
13
  useDocById,
14
14
  } from '@docusaurus/theme-common/internal';
15
15
  import isInternalUrl from '@docusaurus/isInternalUrl';
16
16
  import {translate} from '@docusaurus/Translate';
17
- import type {Props} from '@theme/DocCard';
18
17
 
19
- import styles from './styles.module.css';
18
+ import type {Props} from '@theme/DocCard';
19
+ import Heading from '@theme/Heading';
20
20
  import type {
21
21
  PropSidebarItemCategory,
22
22
  PropSidebarItemLink,
23
23
  } from '@docusaurus/plugin-content-docs';
24
24
 
25
+ import styles from './styles.module.css';
26
+
25
27
  function CardContainer({
26
28
  href,
27
29
  children,
@@ -51,9 +53,12 @@ function CardLayout({
51
53
  }): JSX.Element {
52
54
  return (
53
55
  <CardContainer href={href}>
54
- <h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
56
+ <Heading
57
+ as="h2"
58
+ className={clsx('text--truncate', styles.cardTitle)}
59
+ title={title}>
55
60
  {icon} {title}
56
- </h2>
61
+ </Heading>
57
62
  {description && (
58
63
  <p
59
64
  className={clsx('text--truncate', styles.cardDescription)}
@@ -70,7 +75,7 @@ function CardCategory({
70
75
  }: {
71
76
  item: PropSidebarItemCategory;
72
77
  }): JSX.Element | null {
73
- const href = findFirstCategoryLink(item);
78
+ const href = findFirstSidebarItemLink(item);
74
79
 
75
80
  // Unexpected: categories that don't have a link have been filtered upfront
76
81
  if (!href) {
@@ -17,6 +17,7 @@ import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
17
17
  import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
18
18
  import DocItemContent from '@theme/DocItem/Content';
19
19
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
20
+ import Unlisted from '@theme/Unlisted';
20
21
  import type {Props} from '@theme/DocItem/Layout';
21
22
 
22
23
  import styles from './styles.module.css';
@@ -47,9 +48,13 @@ function useDocTOC() {
47
48
 
48
49
  export default function DocItemLayout({children}: Props): JSX.Element {
49
50
  const docTOC = useDocTOC();
51
+ const {
52
+ metadata: {unlisted},
53
+ } = useDoc();
50
54
  return (
51
55
  <div className="row">
52
56
  <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
57
+ {unlisted && <Unlisted />}
53
58
  <DocVersionBanner />
54
59
  <div className={styles.docItemContainer}>
55
60
  <article>
@@ -13,7 +13,7 @@ import DocItemLayout from '@theme/DocItem/Layout';
13
13
  import type {Props} from '@theme/DocItem';
14
14
 
15
15
  export default function DocItem(props: Props): JSX.Element {
16
- const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
16
+ const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
17
17
  const MDXComponent = props.content;
18
18
  return (
19
19
  <DocProvider content={props.content}>
@@ -8,11 +8,11 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
11
- import type {Props} from '@theme/DocPage/Layout/Main';
11
+ import type {Props} from '@theme/DocRoot/Layout/Main';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- export default function DocPageLayoutMain({
15
+ export default function DocRootLayoutMain({
16
16
  hiddenSidebarContainer,
17
17
  children,
18
18
  }: Props): JSX.Element {
@@ -8,11 +8,11 @@
8
8
  import React from 'react';
9
9
  import {translate} from '@docusaurus/Translate';
10
10
  import IconArrow from '@theme/Icon/Arrow';
11
- import type {Props} from '@theme/DocPage/Layout/Sidebar/ExpandButton';
11
+ import type {Props} from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
15
- export default function DocPageLayoutSidebarExpandButton({
15
+ export default function DocRootLayoutSidebarExpandButton({
16
16
  toggleSidebar,
17
17
  }: Props): JSX.Element {
18
18
  return (
@@ -11,8 +11,8 @@ import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
11
11
  import {useDocsSidebar} from '@docusaurus/theme-common/internal';
12
12
  import {useLocation} from '@docusaurus/router';
13
13
  import DocSidebar from '@theme/DocSidebar';
14
- import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
15
- import type {Props} from '@theme/DocPage/Layout/Sidebar';
14
+ import ExpandButton from '@theme/DocRoot/Layout/Sidebar/ExpandButton';
15
+ import type {Props} from '@theme/DocRoot/Layout/Sidebar';
16
16
 
17
17
  import styles from './styles.module.css';
18
18
 
@@ -28,7 +28,7 @@ function ResetOnSidebarChange({children}: {children: ReactNode}) {
28
28
  );
29
29
  }
30
30
 
31
- export default function DocPageLayoutSidebar({
31
+ export default function DocRootLayoutSidebar({
32
32
  sidebar,
33
33
  hiddenSidebarContainer,
34
34
  setHiddenSidebarContainer,