@docusaurus/theme-classic 2.0.0-beta.8e9b829d9 → 2.0.0-beta.9

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 (275) hide show
  1. package/README.md +1 -1
  2. package/codeTranslations/ar.json +12 -6
  3. package/codeTranslations/base.json +12 -0
  4. package/codeTranslations/bn.json +6 -0
  5. package/codeTranslations/cs.json +62 -0
  6. package/codeTranslations/da.json +6 -0
  7. package/codeTranslations/de.json +8 -2
  8. package/codeTranslations/es.json +10 -4
  9. package/codeTranslations/fa.json +9 -3
  10. package/codeTranslations/fil.json +6 -0
  11. package/codeTranslations/fr.json +6 -0
  12. package/codeTranslations/he.json +6 -0
  13. package/codeTranslations/hi.json +6 -0
  14. package/codeTranslations/ja.json +6 -0
  15. package/codeTranslations/ko.json +6 -0
  16. package/codeTranslations/pl.json +6 -0
  17. package/codeTranslations/pt-BR.json +8 -2
  18. package/codeTranslations/pt-PT.json +6 -0
  19. package/codeTranslations/ru.json +6 -0
  20. package/codeTranslations/sr.json +62 -0
  21. package/codeTranslations/tr.json +9 -3
  22. package/codeTranslations/vi.json +10 -4
  23. package/codeTranslations/zh-Hans.json +6 -0
  24. package/codeTranslations/zh-Hant.json +6 -0
  25. package/lib/__tests__/validateThemeConfig.test.js +154 -4
  26. package/lib/index.js +2 -3
  27. package/lib/prism-include-languages.js +9 -5
  28. package/lib/theme/AnnouncementBar/index.js +8 -12
  29. package/lib/theme/AnnouncementBar/styles.module.css +23 -32
  30. package/lib/theme/BackToTopButton/index.js +27 -13
  31. package/lib/theme/BackToTopButton/styles.module.css +17 -14
  32. package/lib/theme/BlogArchivePage/index.js +89 -0
  33. package/lib/theme/BlogLayout/index.js +2 -6
  34. package/lib/theme/BlogListPage/index.js +1 -1
  35. package/lib/theme/BlogPostAuthor/index.js +51 -0
  36. package/lib/theme/BlogPostAuthor/styles.module.css +12 -0
  37. package/lib/theme/BlogPostAuthors/index.js +47 -0
  38. package/lib/theme/BlogPostAuthors/styles.module.css +11 -0
  39. package/lib/theme/BlogPostItem/index.js +58 -67
  40. package/lib/theme/BlogPostPage/index.js +33 -4
  41. package/lib/theme/BlogSidebar/styles.module.css +2 -2
  42. package/lib/theme/BlogTagsListPage/index.js +3 -28
  43. package/lib/theme/BlogTagsPostsPage/index.js +5 -8
  44. package/lib/theme/CodeBlock/index.js +44 -37
  45. package/lib/theme/CodeBlock/styles.module.css +1 -2
  46. package/lib/theme/DocItem/index.js +15 -40
  47. package/lib/theme/DocItem/styles.module.css +2 -12
  48. package/lib/theme/DocItemFooter/index.js +79 -0
  49. package/lib/theme/DocItemFooter/styles.module.css +18 -0
  50. package/lib/theme/DocPage/index.js +18 -13
  51. package/lib/theme/DocSidebar/index.js +11 -16
  52. package/lib/theme/DocSidebarItem/index.js +12 -10
  53. package/lib/theme/DocTagDocListPage/index.js +89 -0
  54. package/lib/theme/DocTagsListPage/index.js +44 -0
  55. package/lib/theme/DocVersionBanner/index.js +6 -4
  56. package/lib/theme/EditThisPage/index.js +3 -1
  57. package/lib/theme/Footer/index.js +5 -3
  58. package/lib/theme/Heading/index.js +7 -9
  59. package/lib/theme/Heading/styles.css +4 -6
  60. package/lib/theme/Heading/styles.module.css +9 -5
  61. package/lib/theme/IconClose/index.js +31 -0
  62. package/lib/theme/LastUpdated/index.js +4 -2
  63. package/lib/theme/LayoutHead/index.js +13 -11
  64. package/lib/theme/LayoutProviders/index.js +7 -5
  65. package/lib/theme/Logo/index.js +14 -12
  66. package/lib/theme/MDXComponents/index.js +27 -1
  67. package/lib/theme/MDXComponents/styles.css +11 -0
  68. package/lib/theme/MDXPage/index.js +2 -1
  69. package/lib/theme/Navbar/index.js +20 -3
  70. package/lib/theme/Navbar/styles.module.css +5 -1
  71. package/lib/theme/NavbarItem/DefaultNavbarItem.js +12 -4
  72. package/lib/theme/NavbarItem/DocNavbarItem.js +5 -3
  73. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +7 -1
  74. package/lib/theme/NavbarItem/DropdownNavbarItem.js +3 -3
  75. package/lib/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +3 -4
  76. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
  77. package/lib/theme/NavbarItem/index.js +5 -0
  78. package/lib/theme/Seo/index.js +10 -7
  79. package/lib/theme/TOC/index.js +9 -30
  80. package/lib/theme/TOC/styles.module.css +1 -1
  81. package/lib/theme/TOCCollapsible/index.js +5 -3
  82. package/lib/theme/TOCInline/index.js +7 -27
  83. package/lib/theme/TOCItems/index.js +78 -0
  84. package/lib/theme/Tabs/__tests__/index.test.js +123 -0
  85. package/lib/theme/Tabs/index.js +73 -50
  86. package/lib/theme/Tabs/styles.module.css +0 -13
  87. package/lib/theme/Tag/index.js +40 -0
  88. package/lib/theme/Tag/styles.module.css +70 -0
  89. package/lib/theme/TagsListByLetter/index.js +48 -0
  90. package/lib/theme/TagsListByLetter/styles.module.css +11 -0
  91. package/lib/theme/TagsListInline/index.js +44 -0
  92. package/lib/theme/TagsListInline/styles.module.css +15 -0
  93. package/lib/theme/ThemedImage/index.js +3 -5
  94. package/lib/theme/Toggle/index.js +23 -18
  95. package/lib/theme/Toggle/styles.module.css +91 -0
  96. package/lib/theme/hooks/useHideableNavbar.js +14 -31
  97. package/lib/theme/hooks/useTheme.js +2 -2
  98. package/lib/theme/hooks/useWindowSize.js +2 -7
  99. package/lib/theme/prism-include-languages.js +4 -3
  100. package/lib/translations.js +4 -4
  101. package/lib/types.d.ts +216 -105
  102. package/lib/validateThemeConfig.js +215 -254
  103. package/lib-next/__tests__/validateThemeConfig.test.js +154 -4
  104. package/lib-next/index.js +1 -2
  105. package/lib-next/prism-include-languages.js +0 -2
  106. package/lib-next/theme/AnnouncementBar/index.js +7 -12
  107. package/lib-next/theme/AnnouncementBar/styles.module.css +23 -32
  108. package/lib-next/theme/BackToTopButton/index.js +37 -17
  109. package/lib-next/theme/BackToTopButton/styles.module.css +17 -14
  110. package/lib-next/theme/BlogArchivePage/index.js +80 -0
  111. package/lib-next/theme/BlogLayout/index.js +4 -7
  112. package/lib-next/theme/BlogListPage/index.js +1 -0
  113. package/lib-next/theme/BlogPostAuthor/index.js +46 -0
  114. package/lib-next/theme/BlogPostAuthor/styles.module.css +12 -0
  115. package/lib-next/theme/BlogPostAuthors/index.js +34 -0
  116. package/lib-next/theme/BlogPostAuthors/styles.module.css +11 -0
  117. package/lib-next/theme/BlogPostItem/index.js +79 -86
  118. package/lib-next/theme/BlogPostPage/index.js +55 -8
  119. package/lib-next/theme/BlogSidebar/styles.module.css +2 -2
  120. package/lib-next/theme/BlogTagsListPage/index.js +7 -39
  121. package/lib-next/theme/BlogTagsPostsPage/index.js +3 -4
  122. package/lib-next/theme/CodeBlock/index.js +53 -49
  123. package/lib-next/theme/CodeBlock/styles.module.css +1 -2
  124. package/lib-next/theme/DocItem/index.js +27 -45
  125. package/lib-next/theme/DocItem/styles.module.css +2 -12
  126. package/lib-next/theme/DocItemFooter/index.js +79 -0
  127. package/lib-next/theme/DocItemFooter/styles.module.css +18 -0
  128. package/lib-next/theme/DocPage/index.js +18 -14
  129. package/lib-next/theme/DocSidebar/index.js +18 -15
  130. package/lib-next/theme/DocSidebarItem/index.js +31 -11
  131. package/lib-next/theme/DocTagDocListPage/index.js +89 -0
  132. package/lib-next/theme/DocTagsListPage/index.js +38 -0
  133. package/lib-next/theme/DocVersionBanner/index.js +16 -9
  134. package/lib-next/theme/EditThisPage/index.js +6 -1
  135. package/lib-next/theme/Footer/index.js +14 -3
  136. package/lib-next/theme/Heading/index.js +10 -13
  137. package/lib-next/theme/Heading/styles.css +4 -6
  138. package/lib-next/theme/Heading/styles.module.css +9 -5
  139. package/lib-next/theme/IconClose/index.js +23 -0
  140. package/lib-next/theme/LastUpdated/index.js +3 -2
  141. package/lib-next/theme/LayoutHead/index.js +9 -15
  142. package/lib-next/theme/LayoutProviders/index.js +8 -5
  143. package/lib-next/theme/Logo/index.js +23 -19
  144. package/lib-next/theme/MDXComponents/index.js +20 -1
  145. package/lib-next/theme/MDXComponents/styles.css +11 -0
  146. package/lib-next/theme/MDXPage/index.js +10 -2
  147. package/lib-next/theme/Navbar/index.js +27 -3
  148. package/lib-next/theme/Navbar/styles.module.css +5 -1
  149. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +15 -4
  150. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -3
  151. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +12 -4
  152. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -6
  153. package/lib-next/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +2 -6
  154. package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
  155. package/lib-next/theme/NavbarItem/index.js +2 -0
  156. package/lib-next/theme/Seo/index.js +11 -7
  157. package/lib-next/theme/TOC/index.js +12 -36
  158. package/lib-next/theme/TOC/styles.module.css +1 -1
  159. package/lib-next/theme/TOCCollapsible/index.js +12 -3
  160. package/lib-next/theme/TOCInline/index.js +10 -28
  161. package/lib-next/theme/TOCItems/index.js +85 -0
  162. package/lib-next/theme/Tabs/__tests__/index.test.js +142 -0
  163. package/lib-next/theme/Tabs/index.js +91 -43
  164. package/lib-next/theme/Tabs/styles.module.css +0 -13
  165. package/lib-next/theme/Tag/index.js +27 -0
  166. package/lib-next/theme/Tag/styles.module.css +70 -0
  167. package/lib-next/theme/TagsListByLetter/index.js +42 -0
  168. package/lib-next/theme/TagsListByLetter/styles.module.css +11 -0
  169. package/lib-next/theme/TagsListInline/index.js +31 -0
  170. package/lib-next/theme/TagsListInline/styles.module.css +15 -0
  171. package/lib-next/theme/ThemedImage/index.js +3 -3
  172. package/lib-next/theme/Toggle/index.js +20 -15
  173. package/lib-next/theme/Toggle/styles.module.css +91 -0
  174. package/lib-next/theme/hooks/useHideableNavbar.js +31 -47
  175. package/lib-next/theme/hooks/useTheme.js +2 -2
  176. package/lib-next/theme/hooks/useWindowSize.js +2 -6
  177. package/lib-next/theme/prism-include-languages.js +2 -1
  178. package/lib-next/translations.js +6 -10
  179. package/lib-next/types.d.ts +216 -105
  180. package/lib-next/validateThemeConfig.js +40 -36
  181. package/package.json +23 -19
  182. package/src/__tests__/validateThemeConfig.test.js +154 -4
  183. package/src/index.ts +11 -9
  184. package/src/{prism-include-languages.js → prism-include-languages.ts} +0 -0
  185. package/src/theme/AnnouncementBar/index.tsx +8 -12
  186. package/src/theme/AnnouncementBar/styles.module.css +23 -32
  187. package/src/theme/BackToTopButton/index.tsx +39 -17
  188. package/src/theme/BackToTopButton/styles.module.css +17 -14
  189. package/src/theme/BlogArchivePage/index.tsx +91 -0
  190. package/src/theme/BlogLayout/index.tsx +4 -8
  191. package/src/theme/BlogListPage/index.tsx +1 -0
  192. package/src/theme/BlogPostAuthor/index.tsx +49 -0
  193. package/src/theme/BlogPostAuthor/styles.module.css +12 -0
  194. package/src/theme/BlogPostAuthors/index.tsx +36 -0
  195. package/src/theme/BlogPostAuthors/styles.module.css +11 -0
  196. package/src/theme/BlogPostItem/index.tsx +70 -80
  197. package/src/theme/BlogPostPage/index.tsx +57 -8
  198. package/src/theme/BlogSidebar/styles.module.css +2 -2
  199. package/src/theme/BlogTagsListPage/index.tsx +7 -41
  200. package/src/theme/BlogTagsPostsPage/index.tsx +3 -4
  201. package/src/theme/CodeBlock/index.tsx +63 -47
  202. package/src/theme/CodeBlock/styles.module.css +1 -2
  203. package/src/theme/DocItem/index.tsx +27 -46
  204. package/src/theme/DocItem/styles.module.css +2 -12
  205. package/src/theme/DocItemFooter/index.tsx +91 -0
  206. package/src/theme/DocItemFooter/styles.module.css +18 -0
  207. package/src/theme/DocPage/index.tsx +16 -12
  208. package/src/theme/DocSidebar/index.tsx +20 -16
  209. package/src/theme/DocSidebarItem/index.tsx +29 -10
  210. package/src/theme/DocTagDocListPage/index.tsx +89 -0
  211. package/src/theme/DocTagsListPage/index.tsx +41 -0
  212. package/src/theme/DocVersionBanner/index.tsx +26 -15
  213. package/src/theme/EditThisPage/index.tsx +6 -1
  214. package/src/theme/Footer/index.tsx +16 -3
  215. package/src/theme/Heading/index.tsx +10 -13
  216. package/src/theme/Heading/styles.css +4 -6
  217. package/src/theme/Heading/styles.module.css +9 -5
  218. package/src/theme/IconClose/index.tsx +26 -0
  219. package/src/theme/LastUpdated/index.tsx +3 -2
  220. package/src/theme/LayoutHead/index.tsx +9 -9
  221. package/src/theme/LayoutProviders/index.tsx +8 -5
  222. package/src/theme/Logo/index.tsx +19 -15
  223. package/src/theme/MDXComponents/index.tsx +20 -1
  224. package/src/theme/MDXComponents/styles.css +11 -0
  225. package/src/theme/MDXPage/index.tsx +10 -2
  226. package/src/theme/Navbar/index.tsx +26 -2
  227. package/src/theme/Navbar/styles.module.css +5 -1
  228. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +15 -4
  229. package/src/theme/NavbarItem/DocNavbarItem.tsx +9 -5
  230. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +15 -6
  231. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +7 -3
  232. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -6
  233. package/src/theme/NavbarItem/{LocaleDropdownNavbarItem.tsx → LocaleDropdownNavbarItem/index.tsx} +6 -5
  234. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
  235. package/src/theme/NavbarItem/index.tsx +6 -1
  236. package/src/theme/Seo/index.tsx +7 -4
  237. package/src/theme/TOC/index.tsx +13 -38
  238. package/src/theme/TOC/styles.module.css +1 -1
  239. package/src/theme/TOCCollapsible/index.tsx +8 -2
  240. package/src/theme/TOCInline/index.tsx +13 -32
  241. package/src/theme/TOCItems/index.tsx +96 -0
  242. package/src/theme/Tabs/__tests__/index.test.tsx +129 -0
  243. package/src/theme/Tabs/index.tsx +93 -49
  244. package/src/theme/Tabs/styles.module.css +0 -13
  245. package/src/theme/Tag/index.tsx +31 -0
  246. package/src/theme/Tag/styles.module.css +70 -0
  247. package/src/theme/TagsListByLetter/index.tsx +45 -0
  248. package/src/theme/TagsListByLetter/styles.module.css +11 -0
  249. package/src/theme/TagsListInline/index.tsx +35 -0
  250. package/src/theme/TagsListInline/styles.module.css +15 -0
  251. package/src/theme/ThemedImage/index.tsx +3 -3
  252. package/src/theme/Toggle/index.tsx +20 -15
  253. package/src/theme/Toggle/styles.module.css +91 -0
  254. package/src/theme/hooks/useContextualSearchFilters.ts +1 -1
  255. package/src/theme/hooks/useHideableNavbar.ts +32 -47
  256. package/src/theme/hooks/useTabGroupChoice.ts +2 -2
  257. package/src/theme/hooks/useTheme.ts +2 -2
  258. package/src/theme/hooks/useWindowSize.ts +2 -7
  259. package/src/theme/prism-include-languages.ts +3 -2
  260. package/src/translations.ts +6 -10
  261. package/src/types.d.ts +216 -105
  262. package/src/{validateThemeConfig.js → validateThemeConfig.ts} +46 -12
  263. package/tsconfig.json +0 -1
  264. package/update-code-translations.js +5 -4
  265. package/update-code-translations.test.js +1 -1
  266. package/update.js +151 -0
  267. package/lib/theme/Toggle/styles.css +0 -103
  268. package/lib/theme/hooks/useScrollPosition.js +0 -51
  269. package/lib/theme/hooks/useTOCHighlight.js +0 -87
  270. package/lib-next/theme/Toggle/styles.css +0 -103
  271. package/lib-next/theme/hooks/useScrollPosition.js +0 -42
  272. package/lib-next/theme/hooks/useTOCHighlight.js +0 -84
  273. package/src/theme/Toggle/styles.css +0 -103
  274. package/src/theme/hooks/useScrollPosition.ts +0 -52
  275. package/src/theme/hooks/useTOCHighlight.ts +0 -98
@@ -6,19 +6,17 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {useActivePlugin, useVersions} from '@theme/hooks/useDocs';
10
9
  import useWindowSize from '@theme/hooks/useWindowSize';
11
10
  import DocPaginator from '@theme/DocPaginator';
12
11
  import DocVersionBanner from '@theme/DocVersionBanner';
13
12
  import Seo from '@theme/Seo';
14
- import LastUpdated from '@theme/LastUpdated';
13
+ import DocItemFooter from '@theme/DocItemFooter';
15
14
  import TOC from '@theme/TOC';
16
15
  import TOCCollapsible from '@theme/TOCCollapsible';
17
- import EditThisPage from '@theme/EditThisPage';
18
16
  import {MainHeading} from '@theme/Heading';
19
17
  import styles from './styles.module.css';
20
-
21
- function DocItem(props) {
18
+ import {ThemeClassNames} from '@docusaurus/theme-common';
19
+ export default function DocItem(props) {
22
20
  const {content: DocContent, versionMetadata} = props;
23
21
  const {metadata, frontMatter} = DocContent;
24
22
  const {
@@ -26,23 +24,10 @@ function DocItem(props) {
26
24
  keywords,
27
25
  hide_title: hideTitle,
28
26
  hide_table_of_contents: hideTableOfContents,
27
+ toc_min_heading_level: tocMinHeadingLevel,
28
+ toc_max_heading_level: tocMaxHeadingLevel,
29
29
  } = frontMatter;
30
- const {
31
- description,
32
- title,
33
- editUrl,
34
- lastUpdatedAt,
35
- formattedLastUpdatedAt,
36
- lastUpdatedBy,
37
- } = metadata;
38
- const {pluginId} = useActivePlugin({
39
- failfast: true,
40
- });
41
- const versions = useVersions(pluginId); // If site is not versioned or only one version is included
42
- // we don't show the version badge
43
- // See https://github.com/facebook/docusaurus/issues/3362
44
-
45
- const showVersionBadge = versions.length > 1; // We only add a title if:
30
+ const {description, title} = metadata; // We only add a title if:
46
31
  // - user asks to hide it with frontmatter
47
32
  // - the markdown content does not already contain a top-level h1 heading
48
33
 
@@ -72,8 +57,12 @@ function DocItem(props) {
72
57
  <DocVersionBanner versionMetadata={versionMetadata} />
73
58
  <div className={styles.docItemContainer}>
74
59
  <article>
75
- {showVersionBadge && (
76
- <span className="badge badge--secondary">
60
+ {versionMetadata.badge && (
61
+ <span
62
+ className={clsx(
63
+ ThemeClassNames.docs.docVersionBadge,
64
+ 'badge badge--secondary',
65
+ )}>
77
66
  Version: {versionMetadata.label}
78
67
  </span>
79
68
  )}
@@ -81,11 +70,17 @@ function DocItem(props) {
81
70
  {canRenderTOC && (
82
71
  <TOCCollapsible
83
72
  toc={DocContent.toc}
84
- className={styles.tocMobile}
73
+ minHeadingLevel={tocMinHeadingLevel}
74
+ maxHeadingLevel={tocMaxHeadingLevel}
75
+ className={clsx(
76
+ ThemeClassNames.docs.docTocMobile,
77
+ styles.tocMobile,
78
+ )}
85
79
  />
86
80
  )}
87
81
 
88
- <div className="markdown">
82
+ <div
83
+ className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
89
84
  {/*
90
85
  Title can be declared inside md content or declared through frontmatter and added manually
91
86
  To make both cases consistent, the added title is added under the same div.markdown block
@@ -96,23 +91,7 @@ function DocItem(props) {
96
91
  <DocContent />
97
92
  </div>
98
93
 
99
- {(editUrl || lastUpdatedAt || lastUpdatedBy) && (
100
- <footer className="row docusaurus-mt-lg">
101
- <div className="col">
102
- {editUrl && <EditThisPage editUrl={editUrl} />}
103
- </div>
104
-
105
- <div className={clsx('col', styles.lastUpdated)}>
106
- {(lastUpdatedAt || lastUpdatedBy) && (
107
- <LastUpdated
108
- lastUpdatedAt={lastUpdatedAt}
109
- formattedLastUpdatedAt={formattedLastUpdatedAt}
110
- lastUpdatedBy={lastUpdatedBy}
111
- />
112
- )}
113
- </div>
114
- </footer>
115
- )}
94
+ <DocItemFooter {...props} />
116
95
  </article>
117
96
 
118
97
  <DocPaginator metadata={metadata} />
@@ -120,12 +99,15 @@ function DocItem(props) {
120
99
  </div>
121
100
  {renderTocDesktop && (
122
101
  <div className="col col--3">
123
- <TOC toc={DocContent.toc} />
102
+ <TOC
103
+ toc={DocContent.toc}
104
+ minHeadingLevel={tocMinHeadingLevel}
105
+ maxHeadingLevel={tocMaxHeadingLevel}
106
+ className={ThemeClassNames.docs.docTocDesktop}
107
+ />
124
108
  </div>
125
109
  )}
126
110
  </div>
127
111
  </>
128
112
  );
129
113
  }
130
-
131
- export default DocItem;
@@ -5,26 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .docItemContainer article *:first-child,
8
+ .docItemContainer article > *:first-child,
9
9
  .docItemContainer header + * {
10
10
  margin-top: 0;
11
11
  }
12
12
 
13
- .lastUpdated {
14
- margin-top: 0.2rem;
15
- font-style: italic;
16
- font-size: smaller;
17
- }
18
-
19
- @media only screen and (min-width: 997px) {
13
+ @media (min-width: 997px) {
20
14
  .docItemCol {
21
15
  max-width: 75% !important;
22
16
  }
23
17
 
24
- .lastUpdated {
25
- text-align: right;
26
- }
27
-
28
18
  /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
29
19
  .tocMobile {
30
20
  display: none;
@@ -0,0 +1,79 @@
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 LastUpdated from '@theme/LastUpdated';
10
+ import EditThisPage from '@theme/EditThisPage';
11
+ import TagsListInline from '@theme/TagsListInline';
12
+ import styles from './styles.module.css';
13
+ import {ThemeClassNames} from '@docusaurus/theme-common';
14
+
15
+ function TagsRow(props) {
16
+ return (
17
+ <div
18
+ className={clsx(
19
+ ThemeClassNames.docs.docFooterTagsRow,
20
+ 'row margin-bottom--sm',
21
+ )}>
22
+ <div className="col">
23
+ <TagsListInline {...props} />
24
+ </div>
25
+ </div>
26
+ );
27
+ }
28
+
29
+ function EditMetaRow({
30
+ editUrl,
31
+ lastUpdatedAt,
32
+ lastUpdatedBy,
33
+ formattedLastUpdatedAt,
34
+ }) {
35
+ return (
36
+ <div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, 'row')}>
37
+ <div className="col">{editUrl && <EditThisPage editUrl={editUrl} />}</div>
38
+
39
+ <div className={clsx('col', styles.lastUpdated)}>
40
+ {(lastUpdatedAt || lastUpdatedBy) && (
41
+ <LastUpdated
42
+ lastUpdatedAt={lastUpdatedAt}
43
+ formattedLastUpdatedAt={formattedLastUpdatedAt}
44
+ lastUpdatedBy={lastUpdatedBy}
45
+ />
46
+ )}
47
+ </div>
48
+ </div>
49
+ );
50
+ }
51
+
52
+ export default function DocItemFooter(props) {
53
+ const {content: DocContent} = props;
54
+ const {metadata} = DocContent;
55
+ const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} =
56
+ metadata;
57
+ const canDisplayTagsRow = tags.length > 0;
58
+ const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
59
+ const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
60
+
61
+ if (!canDisplayFooter) {
62
+ return <></>;
63
+ }
64
+
65
+ return (
66
+ <footer
67
+ className={clsx(ThemeClassNames.docs.docFooter, 'docusaurus-mt-lg')}>
68
+ {canDisplayTagsRow && <TagsRow tags={tags} />}
69
+ {canDisplayEditMetaRow && (
70
+ <EditMetaRow
71
+ editUrl={editUrl}
72
+ lastUpdatedAt={lastUpdatedAt}
73
+ lastUpdatedBy={lastUpdatedBy}
74
+ formattedLastUpdatedAt={formattedLastUpdatedAt}
75
+ />
76
+ )}
77
+ </footer>
78
+ );
79
+ }
@@ -0,0 +1,18 @@
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
+ .lastUpdated {
9
+ margin-top: 0.2rem;
10
+ font-style: italic;
11
+ font-size: smaller;
12
+ }
13
+
14
+ @media (min-width: 997px) {
15
+ .lastUpdated {
16
+ text-align: right;
17
+ }
18
+ }
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import React, {useState, useCallback} from 'react';
8
8
  import {MDXProvider} from '@mdx-js/react';
9
- import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
9
  import renderRoutes from '@docusaurus/renderRoutes';
11
10
  import Layout from '@theme/Layout';
12
11
  import DocSidebar from '@theme/DocSidebar';
@@ -19,9 +18,9 @@ import {translate} from '@docusaurus/Translate';
19
18
  import clsx from 'clsx';
20
19
  import styles from './styles.module.css';
21
20
  import {ThemeClassNames, docVersionSearchTag} from '@docusaurus/theme-common';
21
+ import Head from '@docusaurus/Head';
22
22
 
23
23
  function DocPageContent({currentDocRoute, versionMetadata, children}) {
24
- const {isClient} = useDocusaurusContext();
25
24
  const {pluginId, version} = versionMetadata;
26
25
  const sidebarName = currentDocRoute.sidebar;
27
26
  const sidebar = sidebarName
@@ -34,13 +33,12 @@ function DocPageContent({currentDocRoute, versionMetadata, children}) {
34
33
  setHiddenSidebar(false);
35
34
  }
36
35
 
37
- setHiddenSidebarContainer(!hiddenSidebarContainer);
36
+ setHiddenSidebarContainer((value) => !value);
38
37
  }, [hiddenSidebar]);
39
38
  return (
40
39
  <Layout
41
- key={isClient}
42
- wrapperClassName={ThemeClassNames.wrapper.docPages}
43
- pageClassName={ThemeClassNames.page.docPage}
40
+ wrapperClassName={ThemeClassNames.wrapper.docsPages}
41
+ pageClassName={ThemeClassNames.page.docsDocPage}
44
42
  searchMetadatas={{
45
43
  version,
46
44
  tag: docVersionSearchTag(pluginId, version),
@@ -132,17 +130,23 @@ function DocPage(props) {
132
130
  );
133
131
 
134
132
  if (!currentDocRoute) {
135
- return <NotFound {...props} />;
133
+ return <NotFound />;
136
134
  }
137
135
 
138
136
  return (
139
- <DocPageContent
140
- currentDocRoute={currentDocRoute}
141
- versionMetadata={versionMetadata}>
142
- {renderRoutes(docRoutes, {
143
- versionMetadata,
144
- })}
145
- </DocPageContent>
137
+ <>
138
+ <Head>
139
+ {/* TODO we should add a core addRoute({htmlClassName}) generic plugin option */}
140
+ <html className={versionMetadata.className} />
141
+ </Head>
142
+ <DocPageContent
143
+ currentDocRoute={currentDocRoute}
144
+ versionMetadata={versionMetadata}>
145
+ {renderRoutes(docRoutes, {
146
+ versionMetadata,
147
+ })}
148
+ </DocPageContent>
149
+ </>
146
150
  );
147
151
  }
148
152
 
@@ -10,9 +10,10 @@ import {
10
10
  useThemeConfig,
11
11
  useAnnouncementBar,
12
12
  MobileSecondaryMenuFiller,
13
+ ThemeClassNames,
14
+ useScrollPosition,
13
15
  } from '@docusaurus/theme-common';
14
16
  import useWindowSize from '@theme/hooks/useWindowSize';
15
- import useScrollPosition from '@theme/hooks/useScrollPosition';
16
17
  import Logo from '@theme/Logo';
17
18
  import IconArrow from '@theme/IconArrow';
18
19
  import {translate} from '@docusaurus/Translate';
@@ -20,14 +21,17 @@ import {DocSidebarItems} from '@theme/DocSidebarItem';
20
21
  import styles from './styles.module.css';
21
22
 
22
23
  function useShowAnnouncementBar() {
23
- const {isClosed} = useAnnouncementBar();
24
- const [showAnnouncementBar, setShowAnnouncementBar] = useState(!isClosed);
25
- useScrollPosition(({scrollY}) => {
26
- if (!isClosed) {
27
- setShowAnnouncementBar(scrollY === 0);
28
- }
29
- });
30
- return showAnnouncementBar;
24
+ const {isActive} = useAnnouncementBar();
25
+ const [showAnnouncementBar, setShowAnnouncementBar] = useState(isActive);
26
+ useScrollPosition(
27
+ ({scrollY}) => {
28
+ if (isActive) {
29
+ setShowAnnouncementBar(scrollY === 0);
30
+ }
31
+ },
32
+ [isActive],
33
+ );
34
+ return isActive && showAnnouncementBar;
31
35
  }
32
36
 
33
37
  function HideableSidebarButton({onClick}) {
@@ -60,7 +64,6 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
60
64
  navbar: {hideOnScroll},
61
65
  hideableSidebar,
62
66
  } = useThemeConfig();
63
- const {isClosed: isAnnouncementBarClosed} = useAnnouncementBar();
64
67
  return (
65
68
  <div
66
69
  className={clsx(styles.sidebar, {
@@ -70,11 +73,10 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
70
73
  {hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
71
74
  <nav
72
75
  className={clsx('menu thin-scrollbar', styles.menu, {
73
- [styles.menuWithAnnouncementBar]:
74
- !isAnnouncementBarClosed && showAnnouncementBar,
76
+ [styles.menuWithAnnouncementBar]: showAnnouncementBar,
75
77
  })}>
76
- <ul className="menu__list">
77
- <DocSidebarItems items={sidebar} activePath={path} />
78
+ <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
79
+ <DocSidebarItems items={sidebar} activePath={path} level={1} />
78
80
  </ul>
79
81
  </nav>
80
82
  {hideableSidebar && <HideableSidebarButton onClick={onCollapse} />}
@@ -84,11 +86,12 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
84
86
 
85
87
  const DocSidebarMobileSecondaryMenu = ({toggleSidebar, sidebar, path}) => {
86
88
  return (
87
- <ul className="menu__list">
89
+ <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
88
90
  <DocSidebarItems
89
91
  items={sidebar}
90
92
  activePath={path}
91
93
  onItemClick={() => toggleSidebar()}
94
+ level={1}
92
95
  />
93
96
  </ul>
94
97
  );
@@ -11,6 +11,7 @@ import {
11
11
  usePrevious,
12
12
  Collapsible,
13
13
  useCollapsible,
14
+ ThemeClassNames,
14
15
  } from '@docusaurus/theme-common';
15
16
  import Link from '@docusaurus/Link';
16
17
  import isInternalUrl from '@docusaurus/isInternalUrl';
@@ -72,11 +73,17 @@ function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
72
73
  if (justBecameActive && collapsed) {
73
74
  setCollapsed(false);
74
75
  }
75
- }, [isActive, wasActive, collapsed]);
76
+ }, [isActive, wasActive, collapsed, setCollapsed]);
76
77
  }
77
78
 
78
- function DocSidebarItemCategory({item, onItemClick, activePath, ...props}) {
79
- const {items, label, collapsible} = item;
79
+ function DocSidebarItemCategory({
80
+ item,
81
+ onItemClick,
82
+ activePath,
83
+ level,
84
+ ...props
85
+ }) {
86
+ const {items, label, collapsible, className} = item;
80
87
  const isActive = isActiveSidebarItem(item, activePath);
81
88
  const {collapsed, setCollapsed, toggleCollapsed} = useCollapsible({
82
89
  // active categories are always initialized as expanded
@@ -96,9 +103,15 @@ function DocSidebarItemCategory({item, onItemClick, activePath, ...props}) {
96
103
  });
97
104
  return (
98
105
  <li
99
- className={clsx('menu__list-item', {
100
- 'menu__list-item--collapsed': collapsed,
101
- })}>
106
+ className={clsx(
107
+ ThemeClassNames.docs.docSidebarItemCategory,
108
+ ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
109
+ 'menu__list-item',
110
+ {
111
+ 'menu__list-item--collapsed': collapsed,
112
+ },
113
+ className,
114
+ )}>
102
115
  {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
103
116
  <a
104
117
  className={clsx('menu__link', {
@@ -125,25 +138,32 @@ function DocSidebarItemCategory({item, onItemClick, activePath, ...props}) {
125
138
  tabIndex={collapsed ? -1 : 0}
126
139
  onItemClick={onItemClick}
127
140
  activePath={activePath}
141
+ level={level + 1}
128
142
  />
129
143
  </Collapsible>
130
144
  </li>
131
145
  );
132
146
  }
133
147
 
134
- function DocSidebarItemLink({item, onItemClick, activePath, ...props}) {
135
- const {href, label} = item;
148
+ function DocSidebarItemLink({item, onItemClick, activePath, level, ...props}) {
149
+ const {href, label, className} = item;
136
150
  const isActive = isActiveSidebarItem(item, activePath);
137
151
  return (
138
- <li className="menu__list-item" key={label}>
152
+ <li
153
+ className={clsx(
154
+ ThemeClassNames.docs.docSidebarItemLink,
155
+ ThemeClassNames.docs.docSidebarItemLinkLevel(level),
156
+ 'menu__list-item',
157
+ className,
158
+ )}
159
+ key={label}>
139
160
  <Link
140
161
  className={clsx('menu__link', {
141
162
  'menu__link--active': isActive,
142
163
  })}
164
+ aria-current={isActive ? 'page' : undefined}
143
165
  to={href}
144
166
  {...(isInternalUrl(href) && {
145
- isNavLink: true,
146
- exact: true,
147
167
  onClick: onItemClick,
148
168
  })}
149
169
  {...props}>
@@ -0,0 +1,89 @@
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 Layout from '@theme/Layout';
9
+ import Link from '@docusaurus/Link';
10
+ import {ThemeClassNames, usePluralForm} from '@docusaurus/theme-common';
11
+ import Translate, {translate} from '@docusaurus/Translate';
12
+
13
+ // Very simple pluralization: probably good enough for now
14
+ function useNDocsTaggedPlural() {
15
+ const {selectMessage} = usePluralForm();
16
+ return (count) =>
17
+ selectMessage(
18
+ count,
19
+ translate(
20
+ {
21
+ id: 'theme.docs.tagDocListPageTitle.nDocsTagged',
22
+ description:
23
+ 'Pluralized label for "{count} docs tagged". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',
24
+ message: 'One doc tagged|{count} docs tagged',
25
+ },
26
+ {
27
+ count,
28
+ },
29
+ ),
30
+ );
31
+ }
32
+
33
+ function DocItem({doc}) {
34
+ return (
35
+ <article className="margin-vert--lg">
36
+ <Link to={doc.permalink}>
37
+ <h2>{doc.title}</h2>
38
+ </Link>
39
+ {doc.description && <p>{doc.description}</p>}
40
+ </article>
41
+ );
42
+ }
43
+
44
+ export default function DocTagDocListPage({tag}) {
45
+ const nDocsTaggedPlural = useNDocsTaggedPlural();
46
+ const title = translate(
47
+ {
48
+ id: 'theme.docs.tagDocListPageTitle',
49
+ description: 'The title of the page for a docs tag',
50
+ message: '{nDocsTagged} with "{tagName}"',
51
+ },
52
+ {
53
+ nDocsTagged: nDocsTaggedPlural(tag.docs.length),
54
+ tagName: tag.name,
55
+ },
56
+ );
57
+ return (
58
+ <Layout
59
+ title={title}
60
+ wrapperClassName={ThemeClassNames.wrapper.docsPages}
61
+ pageClassName={ThemeClassNames.page.docsTagDocListPage}
62
+ searchMetadatas={{
63
+ // assign unique search tag to exclude this page from search results!
64
+ tag: 'doc_tag_doc_list',
65
+ }}>
66
+ <div className="container margin-vert--lg">
67
+ <div className="row">
68
+ <main className="col col--8 col--offset-2">
69
+ <header className="margin-bottom--xl">
70
+ <h1>{title}</h1>
71
+ <Link href={tag.allTagsPath}>
72
+ <Translate
73
+ id="theme.tags.tagsPageLink"
74
+ description="The label of the link targeting the tag list page">
75
+ View All Tags
76
+ </Translate>
77
+ </Link>
78
+ </header>
79
+ <section className="margin-vert--lg">
80
+ {tag.docs.map((doc) => (
81
+ <DocItem key={doc.id} doc={doc} />
82
+ ))}
83
+ </section>
84
+ </main>
85
+ </div>
86
+ </div>
87
+ </Layout>
88
+ );
89
+ }
@@ -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
+ import React from 'react';
8
+ import Layout from '@theme/Layout';
9
+ import {
10
+ ThemeClassNames,
11
+ translateTagsPageTitle,
12
+ } from '@docusaurus/theme-common';
13
+ import TagsListByLetter from '@theme/TagsListByLetter';
14
+
15
+ function DocTagsListPage({tags}) {
16
+ const title = translateTagsPageTitle();
17
+ return (
18
+ <Layout
19
+ title={title}
20
+ wrapperClassName={ThemeClassNames.wrapper.docsPages}
21
+ pageClassName={ThemeClassNames.page.docsTagsListPage}
22
+ searchMetadatas={{
23
+ // assign unique search tag to exclude this page from search results!
24
+ tag: 'doc_tags_list',
25
+ }}>
26
+ <div className="container margin-vert--lg">
27
+ <div className="row">
28
+ <main className="col col--8 col--offset-2">
29
+ <h1>{title}</h1>
30
+ <TagsListByLetter tags={tags} />
31
+ </main>
32
+ </div>
33
+ </div>
34
+ </Layout>
35
+ );
36
+ }
37
+
38
+ export default DocTagsListPage;
@@ -9,7 +9,11 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
9
9
  import Link from '@docusaurus/Link';
10
10
  import Translate from '@docusaurus/Translate';
11
11
  import {useActivePlugin, useDocVersionSuggestions} from '@theme/hooks/useDocs';
12
- import {useDocsPreferredVersion} from '@docusaurus/theme-common';
12
+ import {
13
+ ThemeClassNames,
14
+ useDocsPreferredVersion,
15
+ } from '@docusaurus/theme-common';
16
+ import clsx from 'clsx';
13
17
 
14
18
  function UnreleasedVersionLabel({siteTitle, versionMetadata}) {
15
19
  return (
@@ -92,16 +96,19 @@ function DocVersionBannerEnabled({versionMetadata}) {
92
96
  version.docs.find((doc) => doc.id === version.mainDocId);
93
97
 
94
98
  const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
95
- const {
96
- latestDocSuggestion,
97
- latestVersionSuggestion,
98
- } = useDocVersionSuggestions(pluginId); // try to link to same doc in latest version (not always possible)
99
+ const {latestDocSuggestion, latestVersionSuggestion} =
100
+ useDocVersionSuggestions(pluginId); // try to link to same doc in latest version (not always possible)
99
101
  // fallback to main doc of latest version
100
102
 
101
103
  const latestVersionSuggestedDoc =
102
104
  latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
103
105
  return (
104
- <div className="alert alert--warning margin-bottom--md" role="alert">
106
+ <div
107
+ className={clsx(
108
+ ThemeClassNames.docs.docVersionBanner,
109
+ 'alert alert--warning margin-bottom--md',
110
+ )}
111
+ role="alert">
105
112
  <div>
106
113
  <BannerLabel siteTitle={siteTitle} versionMetadata={versionMetadata} />
107
114
  </div>
@@ -117,11 +124,11 @@ function DocVersionBannerEnabled({versionMetadata}) {
117
124
  }
118
125
 
119
126
  function DocVersionBanner({versionMetadata}) {
120
- if (versionMetadata.banner === 'none') {
121
- return <></>;
122
- } else {
127
+ if (versionMetadata.banner) {
123
128
  return <DocVersionBannerEnabled versionMetadata={versionMetadata} />;
124
129
  }
130
+
131
+ return <></>;
125
132
  }
126
133
 
127
134
  export default DocVersionBanner;
@@ -7,9 +7,14 @@
7
7
  import React from 'react';
8
8
  import Translate from '@docusaurus/Translate';
9
9
  import IconEdit from '@theme/IconEdit';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
10
11
  export default function EditThisPage({editUrl}) {
11
12
  return (
12
- <a href={editUrl} target="_blank" rel="noreferrer noopener">
13
+ <a
14
+ href={editUrl}
15
+ target="_blank"
16
+ rel="noreferrer noopener"
17
+ className={ThemeClassNames.common.editThisPage}>
13
18
  <IconEdit />
14
19
  <Translate
15
20
  id="theme.common.editThisPage"