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

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 (204) hide show
  1. package/lib/admonitions.css +4 -0
  2. package/lib/default.css +3038 -0
  3. package/lib/getSwizzleConfig.js +9 -2
  4. package/lib/index.js +4 -4
  5. package/lib/nprogress.css +41 -0
  6. package/lib/nprogress.js +46 -0
  7. package/lib/theme-classic.d.ts +315 -33
  8. package/lib/validateThemeConfig.js +72 -14
  9. package/lib-next/theme/BackToTopButton/index.js +6 -102
  10. package/lib-next/theme/BlogLayout/index.js +1 -5
  11. package/lib-next/theme/BlogListPaginator/index.js +25 -28
  12. package/lib-next/theme/BlogPostAuthor/index.js +3 -6
  13. package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
  14. package/lib-next/theme/BlogPostPaginator/index.js +25 -28
  15. package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
  16. package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
  17. package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
  18. package/lib-next/theme/BlogSidebar/index.js +11 -31
  19. package/lib-next/theme/BlogTagsListPage/index.js +2 -3
  20. package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
  21. package/lib-next/theme/CodeBlock/Container/index.js +29 -0
  22. package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
  23. package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
  24. package/lib-next/theme/CodeBlock/Content/String.js +104 -0
  25. package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
  26. package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
  27. package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
  28. package/lib-next/theme/CodeBlock/Line/index.js +49 -0
  29. package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
  30. package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
  31. package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
  32. package/lib-next/theme/CodeBlock/index.js +27 -133
  33. package/lib-next/theme/Details/index.js +1 -1
  34. package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
  35. package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
  36. package/lib-next/theme/DocCardList/index.js +6 -4
  37. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
  38. package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
  39. package/lib-next/theme/DocItem/index.js +1 -1
  40. package/lib-next/theme/DocItem/styles.module.css +6 -0
  41. package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
  42. package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
  43. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
  44. package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
  45. package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
  46. package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  47. package/lib-next/theme/DocPage/Layout/index.js +34 -0
  48. package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
  49. package/lib-next/theme/DocPage/index.js +28 -146
  50. package/lib-next/theme/DocPaginator/index.js +25 -28
  51. package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
  52. package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
  53. package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
  54. package/lib-next/theme/DocSidebarItem/Category.js +197 -0
  55. package/lib-next/theme/DocSidebarItem/Html.js +27 -0
  56. package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
  57. package/lib-next/theme/DocSidebarItem/Link.js +53 -0
  58. package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
  59. package/lib-next/theme/DocSidebarItem/index.js +4 -246
  60. package/lib-next/theme/DocSidebarItems/index.js +1 -6
  61. package/lib-next/theme/DocTagDocListPage/index.js +3 -3
  62. package/lib-next/theme/DocVersionBanner/index.js +2 -2
  63. package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
  64. package/lib-next/theme/Heading/index.js +4 -20
  65. package/lib-next/theme/IconHome/index.js +17 -0
  66. package/lib-next/theme/LastUpdated/index.js +1 -0
  67. package/lib-next/theme/Layout/index.js +1 -1
  68. package/lib-next/theme/MDXComponents/Ul.js +2 -4
  69. package/lib-next/theme/Navbar/Content/index.js +6 -1
  70. package/lib-next/theme/Navbar/Logo/index.js +1 -1
  71. package/lib-next/theme/Navbar/Search/index.js +11 -0
  72. package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
  73. package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
  74. package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
  75. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
  76. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
  77. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
  78. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
  79. package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
  80. package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
  81. package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
  82. package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
  83. package/lib-next/theme/NavbarItem/index.js +4 -23
  84. package/lib-next/theme/NavbarItem/utils.js +2 -1
  85. package/lib-next/theme/PaginatorNavLink/index.js +8 -2
  86. package/lib-next/theme/SiteMetadata/index.js +8 -7
  87. package/lib-next/theme/SkipToContent/index.js +3 -29
  88. package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
  89. package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
  90. package/lib-next/theme/TOCCollapsible/index.js +3 -13
  91. package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
  92. package/lib-next/theme/TOCItems/Tree.js +40 -0
  93. package/lib-next/theme/TOCItems/index.js +3 -34
  94. package/lib-next/theme/TabItem/index.js +3 -1
  95. package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
  96. package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
  97. package/lib-next/theme/Tabs/index.js +3 -3
  98. package/lib-next/theme/Tabs/styles.module.css +4 -0
  99. package/lib-next/theme/Tag/index.js +2 -3
  100. package/lib-next/theme/TagsListInline/index.js +1 -1
  101. package/package.json +23 -18
  102. package/src/admonitions.css +4 -0
  103. package/src/getSwizzleConfig.ts +10 -2
  104. package/src/index.ts +4 -3
  105. package/src/nprogress.css +41 -0
  106. package/src/nprogress.ts +31 -0
  107. package/src/theme/BackToTopButton/index.tsx +5 -112
  108. package/src/theme/BlogLayout/index.tsx +1 -5
  109. package/src/theme/BlogListPaginator/index.tsx +25 -28
  110. package/src/theme/BlogPostAuthor/index.tsx +3 -7
  111. package/src/theme/BlogPostItem/styles.module.css +9 -0
  112. package/src/theme/BlogPostPaginator/index.tsx +25 -28
  113. package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
  114. package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
  115. package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
  116. package/src/theme/BlogSidebar/index.tsx +10 -31
  117. package/src/theme/BlogTagsListPage/index.tsx +2 -3
  118. package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
  119. package/src/theme/CodeBlock/Container/index.tsx +35 -0
  120. package/src/theme/CodeBlock/Container/styles.module.css +14 -0
  121. package/src/theme/CodeBlock/Content/Element.tsx +30 -0
  122. package/src/theme/CodeBlock/Content/String.tsx +111 -0
  123. package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
  124. package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
  125. package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
  126. package/src/theme/CodeBlock/Line/index.tsx +48 -0
  127. package/src/theme/CodeBlock/Line/styles.module.css +51 -0
  128. package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
  129. package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
  130. package/src/theme/CodeBlock/index.tsx +29 -133
  131. package/src/theme/Details/index.tsx +1 -1
  132. package/src/theme/DocBreadcrumbs/index.tsx +50 -20
  133. package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
  134. package/src/theme/DocCardList/index.tsx +5 -7
  135. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
  136. package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
  137. package/src/theme/DocItem/index.tsx +1 -1
  138. package/src/theme/DocItem/styles.module.css +6 -0
  139. package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
  140. package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
  141. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
  142. package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
  143. package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
  144. package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
  145. package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
  146. package/src/theme/DocPage/Layout/index.tsx +39 -0
  147. package/src/theme/DocPage/index.tsx +28 -157
  148. package/src/theme/DocPaginator/index.tsx +25 -28
  149. package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
  150. package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
  151. package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
  152. package/src/theme/DocSidebarItem/Category.tsx +210 -0
  153. package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
  154. package/src/theme/DocSidebarItem/Html.tsx +34 -0
  155. package/src/theme/DocSidebarItem/Link.module.css +10 -0
  156. package/src/theme/DocSidebarItem/Link.tsx +58 -0
  157. package/src/theme/DocSidebarItem/index.tsx +4 -259
  158. package/src/theme/DocSidebarItems/index.tsx +1 -6
  159. package/src/theme/DocTagDocListPage/index.tsx +3 -4
  160. package/src/theme/DocVersionBanner/index.tsx +2 -2
  161. package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
  162. package/src/theme/Heading/index.tsx +4 -18
  163. package/src/theme/IconHome/index.tsx +20 -0
  164. package/src/theme/LastUpdated/index.tsx +1 -0
  165. package/src/theme/Layout/index.tsx +1 -1
  166. package/src/theme/MDXComponents/Details.tsx +2 -3
  167. package/src/theme/MDXComponents/Ul.tsx +2 -6
  168. package/src/theme/Navbar/Content/index.tsx +6 -1
  169. package/src/theme/Navbar/Logo/index.tsx +1 -1
  170. package/src/theme/Navbar/Search/index.tsx +15 -0
  171. package/src/theme/Navbar/Search/styles.module.css +20 -0
  172. package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
  173. package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
  174. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
  175. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
  176. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
  177. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
  178. package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
  179. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
  180. package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
  181. package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
  182. package/src/theme/NavbarItem/index.tsx +9 -38
  183. package/src/theme/NavbarItem/utils.ts +5 -2
  184. package/src/theme/PaginatorNavLink/index.tsx +8 -2
  185. package/src/theme/SiteMetadata/index.tsx +8 -8
  186. package/src/theme/SkipToContent/index.tsx +3 -29
  187. package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
  188. package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
  189. package/src/theme/TOCCollapsible/index.module.css +31 -0
  190. package/src/theme/TOCCollapsible/index.tsx +3 -14
  191. package/src/theme/TOCItems/Tree.tsx +46 -0
  192. package/src/theme/TOCItems/index.tsx +2 -41
  193. package/src/theme/TabItem/index.tsx +7 -1
  194. package/src/theme/TabItem/styles.module.css +10 -0
  195. package/src/theme/Tabs/index.tsx +3 -3
  196. package/src/theme/Tabs/styles.module.css +4 -0
  197. package/src/theme/Tag/index.tsx +2 -4
  198. package/src/theme/TagsListInline/index.tsx +1 -1
  199. package/src/theme-classic.d.ts +315 -33
  200. package/src/validateThemeConfig.ts +80 -13
  201. package/lib/types.d.ts +0 -11
  202. package/lib-next/theme/DocPage/styles.module.css +0 -82
  203. package/src/theme/DocPage/styles.module.css +0 -82
  204. package/src/types.d.ts +0 -11
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ThemeConfigSchema = exports.DEFAULT_CONFIG = void 0;
7
7
  exports.validateThemeConfig = validateThemeConfig;
8
8
 
9
+ var _palenight = _interopRequireDefault(require("prism-react-renderer/themes/palenight"));
10
+
9
11
  var _utilsValidation = require("@docusaurus/utils-validation");
10
12
 
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
11
15
  /**
12
16
  * Copyright (c) Facebook, Inc. and its affiliates.
13
17
  *
@@ -15,11 +19,19 @@ var _utilsValidation = require("@docusaurus/utils-validation");
15
19
  * LICENSE file in the root directory of this source tree.
16
20
  */
17
21
  const DEFAULT_DOCS_CONFIG = {
18
- versionPersistence: 'localStorage'
22
+ versionPersistence: 'localStorage',
23
+ sidebar: {
24
+ hideable: false,
25
+ autoCollapseCategories: false
26
+ }
19
27
  };
20
28
 
21
29
  const DocsSchema = _utilsValidation.Joi.object({
22
- versionPersistence: _utilsValidation.Joi.string().equal('localStorage', 'none').default(DEFAULT_DOCS_CONFIG.versionPersistence)
30
+ versionPersistence: _utilsValidation.Joi.string().equal('localStorage', 'none').default(DEFAULT_DOCS_CONFIG.versionPersistence),
31
+ sidebar: _utilsValidation.Joi.object({
32
+ hideable: _utilsValidation.Joi.bool().default(DEFAULT_DOCS_CONFIG.sidebar.hideable),
33
+ autoCollapseCategories: _utilsValidation.Joi.bool().default(DEFAULT_DOCS_CONFIG.sidebar.autoCollapseCategories)
34
+ }).default(DEFAULT_DOCS_CONFIG.sidebar)
23
35
  }).default(DEFAULT_DOCS_CONFIG);
24
36
 
25
37
  const DEFAULT_COLOR_MODE_CONFIG = {
@@ -32,14 +44,21 @@ const DEFAULT_CONFIG = {
32
44
  docs: DEFAULT_DOCS_CONFIG,
33
45
  metadata: [],
34
46
  prism: {
35
- additionalLanguages: []
47
+ additionalLanguages: [],
48
+ theme: _palenight.default,
49
+ magicComments: [{
50
+ className: 'theme-code-block-highlighted-line',
51
+ line: 'highlight-next-line',
52
+ block: {
53
+ start: 'highlight-start',
54
+ end: 'highlight-end'
55
+ }
56
+ }]
36
57
  },
37
58
  navbar: {
38
59
  hideOnScroll: false,
39
60
  items: []
40
61
  },
41
- hideableSidebar: false,
42
- autoCollapseSidebarCategories: false,
43
62
  tableOfContents: {
44
63
  minHeadingLevel: 2,
45
64
  maxHeadingLevel: 3
@@ -51,8 +70,9 @@ const NavbarItemPosition = _utilsValidation.Joi.string().equal('left', 'right').
51
70
 
52
71
  const NavbarItemBaseSchema = _utilsValidation.Joi.object({
53
72
  label: _utilsValidation.Joi.string(),
73
+ html: _utilsValidation.Joi.string(),
54
74
  className: _utilsValidation.Joi.string()
55
- }) // We allow any unknown attributes on the links (users may need additional
75
+ }).nand('html', 'label') // We allow any unknown attributes on the links (users may need additional
56
76
  // attributes like target, aria-role, data-customAttribute...)
57
77
  .unknown();
58
78
 
@@ -85,9 +105,24 @@ const DocSidebarItemSchema = NavbarItemBaseSchema.append({
85
105
  docsPluginId: _utilsValidation.Joi.string()
86
106
  });
87
107
 
108
+ const HtmlNavbarItemSchema = _utilsValidation.Joi.object({
109
+ className: _utilsValidation.Joi.string(),
110
+ type: _utilsValidation.Joi.string().equal('html').required(),
111
+ value: _utilsValidation.Joi.string().required()
112
+ }); // A temporary workaround to allow users to add custom navbar items
113
+ // See https://github.com/facebook/docusaurus/issues/7227
114
+
115
+
116
+ const CustomNavbarItemRegexp = /custom-.*/;
117
+
118
+ const CustomNavbarItemSchema = _utilsValidation.Joi.object({
119
+ type: _utilsValidation.Joi.string().regex(CustomNavbarItemRegexp).required()
120
+ }).unknown();
121
+
88
122
  const itemWithType = type => {
89
- // because equal(undefined) is not supported :/
90
- const typeSchema = type ? _utilsValidation.Joi.string().required().equal(type) : _utilsValidation.Joi.string().forbidden();
123
+ // Because equal(undefined) is not supported :/
124
+ const typeSchema = // eslint-disable-next-line no-nested-ternary
125
+ type instanceof RegExp ? _utilsValidation.Joi.string().required().regex(type) : type ? _utilsValidation.Joi.string().required().equal(type) : _utilsValidation.Joi.string().forbidden();
91
126
  return _utilsValidation.Joi.object({
92
127
  type: typeSchema
93
128
  }).unknown().required();
@@ -108,6 +143,12 @@ const DropdownSubitemSchema = _utilsValidation.Joi.object({
108
143
  }, {
109
144
  is: itemWithType(undefined),
110
145
  then: DefaultNavbarItemSchema
146
+ }, {
147
+ is: itemWithType('html'),
148
+ then: HtmlNavbarItemSchema
149
+ }, {
150
+ is: itemWithType(CustomNavbarItemRegexp),
151
+ then: CustomNavbarItemSchema
111
152
  }, {
112
153
  is: _utilsValidation.Joi.alternatives().try(itemWithType('dropdown'), itemWithType('docsVersionDropdown'), itemWithType('localeDropdown'), itemWithType('search')),
113
154
  then: _utilsValidation.Joi.forbidden().messages({
@@ -163,6 +204,12 @@ const NavbarItemSchema = _utilsValidation.Joi.object({
163
204
  }, {
164
205
  is: itemWithType('search'),
165
206
  then: SearchItemSchema
207
+ }, {
208
+ is: itemWithType('html'),
209
+ then: HtmlNavbarItemSchema
210
+ }, {
211
+ is: itemWithType(CustomNavbarItemRegexp),
212
+ then: CustomNavbarItemSchema
166
213
  }, {
167
214
  is: itemWithType(undefined),
168
215
  then: _utilsValidation.Joi.object().when('.', {
@@ -186,8 +233,7 @@ const ColorModeSchema = _utilsValidation.Joi.object({
186
233
  switchConfig: _utilsValidation.Joi.any().forbidden().messages({
187
234
  'any.unknown': 'colorMode.switchConfig is deprecated. If you want to customize the icons for light and dark mode, swizzle IconLightMode, IconDarkMode, or ColorModeToggle instead.'
188
235
  })
189
- }).default(DEFAULT_COLOR_MODE_CONFIG); // schema can probably be improved
190
-
236
+ }).default(DEFAULT_COLOR_MODE_CONFIG);
191
237
 
192
238
  const HtmlMetadataSchema = _utilsValidation.Joi.object({
193
239
  id: _utilsValidation.Joi.string(),
@@ -276,16 +322,28 @@ const ThemeConfigSchema = _utilsValidation.Joi.object({
276
322
  theme: _utilsValidation.Joi.object({
277
323
  plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
278
324
  styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
279
- }),
325
+ }).default(DEFAULT_CONFIG.prism.theme),
280
326
  darkTheme: _utilsValidation.Joi.object({
281
327
  plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
282
328
  styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
283
329
  }),
284
330
  defaultLanguage: _utilsValidation.Joi.string(),
285
- additionalLanguages: _utilsValidation.Joi.array().items(_utilsValidation.Joi.string()).default(DEFAULT_CONFIG.prism.additionalLanguages)
331
+ additionalLanguages: _utilsValidation.Joi.array().items(_utilsValidation.Joi.string()).default(DEFAULT_CONFIG.prism.additionalLanguages),
332
+ magicComments: _utilsValidation.Joi.array().items(_utilsValidation.Joi.object({
333
+ className: _utilsValidation.Joi.string().required(),
334
+ line: _utilsValidation.Joi.string(),
335
+ block: _utilsValidation.Joi.object({
336
+ start: _utilsValidation.Joi.string().required(),
337
+ end: _utilsValidation.Joi.string().required()
338
+ })
339
+ }).or('line', 'block')).default(DEFAULT_CONFIG.prism.magicComments)
286
340
  }).default(DEFAULT_CONFIG.prism).unknown(),
287
- hideableSidebar: _utilsValidation.Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
288
- autoCollapseSidebarCategories: _utilsValidation.Joi.bool().default(DEFAULT_CONFIG.autoCollapseSidebarCategories),
341
+ hideableSidebar: _utilsValidation.Joi.forbidden().messages({
342
+ 'any.unknown': 'themeConfig.hideableSidebar has been moved to themeConfig.docs.sidebar.hideable.'
343
+ }),
344
+ autoCollapseSidebarCategories: _utilsValidation.Joi.forbidden().messages({
345
+ 'any.unknown': 'themeConfig.autoCollapseSidebarCategories has been moved to themeConfig.docs.sidebar.autoCollapseCategories.'
346
+ }),
289
347
  sidebarCollapsible: _utilsValidation.Joi.forbidden().messages({
290
348
  'any.unknown': 'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs'
291
349
  }),
@@ -4,110 +4,14 @@
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
- import React, {useRef, useState} from 'react';
7
+ import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {translate} from '@docusaurus/Translate';
10
+ import {ThemeClassNames, useBackToTopButton} from '@docusaurus/theme-common';
10
11
  import styles from './styles.module.css';
11
- import {
12
- ThemeClassNames,
13
- useScrollPosition,
14
- useLocationChange,
15
- } from '@docusaurus/theme-common';
16
- const threshold = 300; // Not all have support for smooth scrolling (particularly Safari mobile iOS)
17
- // TODO proper detection is currently unreliable!
18
- // see https://github.com/wessberg/scroll-behavior-polyfill/issues/16
19
-
20
- const SupportsNativeSmoothScrolling = false; // const SupportsNativeSmoothScrolling =
21
- // ExecutionEnvironment.canUseDOM &&
22
- // 'scrollBehavior' in document.documentElement.style;
23
-
24
- function smoothScrollTopNative() {
25
- window.scrollTo({
26
- top: 0,
27
- behavior: 'smooth',
28
- });
29
- return () => {
30
- // Nothing to cancel, it's natively cancelled if user tries to scroll down
31
- };
32
- }
33
-
34
- function smoothScrollTopPolyfill() {
35
- let raf = null;
36
-
37
- function rafRecursion() {
38
- const currentScroll = document.documentElement.scrollTop;
39
-
40
- if (currentScroll > 0) {
41
- raf = requestAnimationFrame(rafRecursion);
42
- window.scrollTo(0, Math.floor(currentScroll * 0.85));
43
- }
44
- }
45
-
46
- rafRecursion(); // Break the recursion. Prevents the user from "fighting" against that
47
- // recursion producing a weird UX
48
-
49
- return () => raf && cancelAnimationFrame(raf);
50
- }
51
-
52
- function useSmoothScrollToTop() {
53
- const lastCancelRef = useRef(null);
54
-
55
- function smoothScrollTop() {
56
- lastCancelRef.current = SupportsNativeSmoothScrolling
57
- ? smoothScrollTopNative()
58
- : smoothScrollTopPolyfill();
59
- }
60
-
61
- return {
62
- smoothScrollTop,
63
- cancelScrollToTop: () => lastCancelRef.current?.(),
64
- };
65
- }
66
-
67
12
  export default function BackToTopButton() {
68
- const [show, setShow] = useState(false);
69
- const isFocusedAnchor = useRef(false);
70
- const {smoothScrollTop, cancelScrollToTop} = useSmoothScrollToTop();
71
- useScrollPosition(({scrollY: scrollTop}, lastPosition) => {
72
- const lastScrollTop = lastPosition?.scrollY; // No lastScrollTop means component is just being mounted.
73
- // Not really a scroll event from the user, so we ignore it
74
-
75
- if (!lastScrollTop) {
76
- return;
77
- }
78
-
79
- if (isFocusedAnchor.current) {
80
- isFocusedAnchor.current = false;
81
- return;
82
- }
83
-
84
- const isScrollingUp = scrollTop < lastScrollTop;
85
-
86
- if (!isScrollingUp) {
87
- cancelScrollToTop();
88
- }
89
-
90
- if (scrollTop < threshold) {
91
- setShow(false);
92
- return;
93
- }
94
-
95
- if (isScrollingUp) {
96
- const documentHeight = document.documentElement.scrollHeight;
97
- const windowHeight = window.innerHeight;
98
-
99
- if (scrollTop + windowHeight < documentHeight) {
100
- setShow(true);
101
- }
102
- } else {
103
- setShow(false);
104
- }
105
- });
106
- useLocationChange((locationChangeEvent) => {
107
- if (locationChangeEvent.location.hash) {
108
- isFocusedAnchor.current = true;
109
- setShow(false);
110
- }
13
+ const {shown, scrollToTop} = useBackToTopButton({
14
+ threshold: 300,
111
15
  });
112
16
  return (
113
17
  <button
@@ -120,10 +24,10 @@ export default function BackToTopButton() {
120
24
  'clean-btn',
121
25
  ThemeClassNames.common.backToTopButton,
122
26
  styles.backToTopButton,
123
- show && styles.backToTopButtonShow,
27
+ shown && styles.backToTopButtonShow,
124
28
  )}
125
29
  type="button"
126
- onClick={() => smoothScrollTop()}
30
+ onClick={scrollToTop}
127
31
  />
128
32
  );
129
33
  }
@@ -15,11 +15,7 @@ export default function BlogLayout(props) {
15
15
  <Layout {...layoutProps}>
16
16
  <div className="container margin-vert--lg">
17
17
  <div className="row">
18
- {hasSidebar && (
19
- <aside className="col col--3">
20
- <BlogSidebar sidebar={sidebar} />
21
- </aside>
22
- )}
18
+ <BlogSidebar sidebar={sidebar} />
23
19
  <main
24
20
  className={clsx('col', {
25
21
  'col--7': hasSidebar,
@@ -18,34 +18,31 @@ export default function BlogListPaginator(props) {
18
18
  message: 'Blog list page navigation',
19
19
  description: 'The ARIA label for the blog pagination',
20
20
  })}>
21
- <div className="pagination-nav__item">
22
- {previousPage && (
23
- <PaginatorNavLink
24
- permalink={previousPage}
25
- title={
26
- <Translate
27
- id="theme.blog.paginator.newerEntries"
28
- description="The label used to navigate to the newer blog posts page (previous page)">
29
- Newer Entries
30
- </Translate>
31
- }
32
- />
33
- )}
34
- </div>
35
- <div className="pagination-nav__item pagination-nav__item--next">
36
- {nextPage && (
37
- <PaginatorNavLink
38
- permalink={nextPage}
39
- title={
40
- <Translate
41
- id="theme.blog.paginator.olderEntries"
42
- description="The label used to navigate to the older blog posts page (next page)">
43
- Older Entries
44
- </Translate>
45
- }
46
- />
47
- )}
48
- </div>
21
+ {previousPage && (
22
+ <PaginatorNavLink
23
+ permalink={previousPage}
24
+ title={
25
+ <Translate
26
+ id="theme.blog.paginator.newerEntries"
27
+ description="The label used to navigate to the newer blog posts page (previous page)">
28
+ Newer Entries
29
+ </Translate>
30
+ }
31
+ />
32
+ )}
33
+ {nextPage && (
34
+ <PaginatorNavLink
35
+ permalink={nextPage}
36
+ title={
37
+ <Translate
38
+ id="theme.blog.paginator.olderEntries"
39
+ description="The label used to navigate to the older blog posts page (next page)">
40
+ Older Entries
41
+ </Translate>
42
+ }
43
+ isNext
44
+ />
45
+ )}
49
46
  </nav>
50
47
  );
51
48
  }
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import Link from '@docusaurus/Link';
9
- import styles from './styles.module.css';
10
9
 
11
10
  function MaybeLink(props) {
12
11
  if (props.href) {
@@ -22,11 +21,9 @@ export default function BlogPostAuthor({author}) {
22
21
  return (
23
22
  <div className="avatar margin-bottom--sm">
24
23
  {imageURL && (
25
- <span className="avatar__photo-link avatar__photo">
26
- <MaybeLink href={link}>
27
- <img className={styles.image} src={imageURL} alt={name} />
28
- </MaybeLink>
29
- </span>
24
+ <MaybeLink href={link} className="avatar__photo-link">
25
+ <img className="avatar__photo" src={imageURL} alt={name} />
26
+ </MaybeLink>
30
27
  )}
31
28
 
32
29
  {name && (
@@ -9,6 +9,15 @@
9
9
  font-size: 3rem;
10
10
  }
11
11
 
12
+ /**
13
+ Blog post title should be smaller on smaller devices
14
+ **/
15
+ @media (max-width: 576px) {
16
+ .blogPostTitle {
17
+ font-size: 2rem;
18
+ }
19
+ }
20
+
12
21
  .blogPostData {
13
22
  font-size: 0.9rem;
14
23
  }
@@ -17,34 +17,31 @@ export default function BlogPostPaginator(props) {
17
17
  message: 'Blog post page navigation',
18
18
  description: 'The ARIA label for the blog posts pagination',
19
19
  })}>
20
- <div className="pagination-nav__item">
21
- {prevItem && (
22
- <PaginatorNavLink
23
- {...prevItem}
24
- subLabel={
25
- <Translate
26
- id="theme.blog.post.paginator.newerPost"
27
- description="The blog post button label to navigate to the newer/previous post">
28
- Newer Post
29
- </Translate>
30
- }
31
- />
32
- )}
33
- </div>
34
- <div className="pagination-nav__item pagination-nav__item--next">
35
- {nextItem && (
36
- <PaginatorNavLink
37
- {...nextItem}
38
- subLabel={
39
- <Translate
40
- id="theme.blog.post.paginator.olderPost"
41
- description="The blog post button label to navigate to the older/next post">
42
- Older Post
43
- </Translate>
44
- }
45
- />
46
- )}
47
- </div>
20
+ {prevItem && (
21
+ <PaginatorNavLink
22
+ {...prevItem}
23
+ subLabel={
24
+ <Translate
25
+ id="theme.blog.post.paginator.newerPost"
26
+ description="The blog post button label to navigate to the newer/previous post">
27
+ Newer Post
28
+ </Translate>
29
+ }
30
+ />
31
+ )}
32
+ {nextItem && (
33
+ <PaginatorNavLink
34
+ {...nextItem}
35
+ subLabel={
36
+ <Translate
37
+ id="theme.blog.post.paginator.olderPost"
38
+ description="The blog post button label to navigate to the older/next post">
39
+ Older Post
40
+ </Translate>
41
+ }
42
+ isNext
43
+ />
44
+ )}
48
45
  </nav>
49
46
  );
50
47
  }
@@ -0,0 +1,41 @@
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 Link from '@docusaurus/Link';
10
+ import {translate} from '@docusaurus/Translate';
11
+ import styles from './styles.module.css';
12
+ export default function BlogSidebarDesktop({sidebar}) {
13
+ return (
14
+ <aside className="col col--3">
15
+ <nav
16
+ className={clsx(styles.sidebar, 'thin-scrollbar')}
17
+ aria-label={translate({
18
+ id: 'theme.blog.sidebar.navAriaLabel',
19
+ message: 'Blog recent posts navigation',
20
+ description: 'The ARIA label for recent posts in the blog sidebar',
21
+ })}>
22
+ <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
23
+ {sidebar.title}
24
+ </div>
25
+ <ul className={clsx(styles.sidebarItemList, 'clean-list')}>
26
+ {sidebar.items.map((item) => (
27
+ <li key={item.permalink} className={styles.sidebarItem}>
28
+ <Link
29
+ isNavLink
30
+ to={item.permalink}
31
+ className={styles.sidebarItemLink}
32
+ activeClassName={styles.sidebarItemLinkActive}>
33
+ {item.title}
34
+ </Link>
35
+ </li>
36
+ ))}
37
+ </ul>
38
+ </nav>
39
+ </aside>
40
+ );
41
+ }
@@ -18,9 +18,7 @@
18
18
  }
19
19
 
20
20
  .sidebarItemList {
21
- list-style: none;
22
21
  font-size: 0.9rem;
23
- padding-left: 0;
24
22
  }
25
23
 
26
24
  .sidebarItem {
@@ -29,6 +27,7 @@
29
27
 
30
28
  .sidebarItemLink {
31
29
  color: var(--ifm-font-color-base);
30
+ display: block;
32
31
  }
33
32
 
34
33
  .sidebarItemLink:hover {
@@ -0,0 +1,36 @@
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 Link from '@docusaurus/Link';
9
+ import {NavbarSecondaryMenuFiller} from '@docusaurus/theme-common';
10
+
11
+ function BlogSidebarMobileSecondaryMenu({sidebar}) {
12
+ return (
13
+ <ul className="menu__list">
14
+ {sidebar.items.map((item) => (
15
+ <li key={item.permalink} className="menu__list-item">
16
+ <Link
17
+ isNavLink
18
+ to={item.permalink}
19
+ className="menu__link"
20
+ activeClassName="menu__link--active">
21
+ {item.title}
22
+ </Link>
23
+ </li>
24
+ ))}
25
+ </ul>
26
+ );
27
+ }
28
+
29
+ export default function BlogSidebarMobile(props) {
30
+ return (
31
+ <NavbarSecondaryMenuFiller
32
+ component={BlogSidebarMobileSecondaryMenu}
33
+ props={props}
34
+ />
35
+ );
36
+ }
@@ -5,39 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
- import Link from '@docusaurus/Link';
10
- import styles from './styles.module.css';
11
- import {translate} from '@docusaurus/Translate';
8
+ import BlogSidebarDesktop from '@theme/BlogSidebar/Desktop';
9
+ import BlogSidebarMobile from '@theme/BlogSidebar/Mobile';
10
+ import {useWindowSize} from '@docusaurus/theme-common';
12
11
  export default function BlogSidebar({sidebar}) {
13
- if (sidebar.items.length === 0) {
12
+ const windowSize = useWindowSize();
13
+
14
+ if (!sidebar?.items.length) {
14
15
  return null;
16
+ } // Mobile sidebar doesn't need to be server-rendered
17
+
18
+ if (windowSize === 'mobile') {
19
+ return <BlogSidebarMobile sidebar={sidebar} />;
15
20
  }
16
21
 
17
- return (
18
- <nav
19
- className={clsx(styles.sidebar, 'thin-scrollbar')}
20
- aria-label={translate({
21
- id: 'theme.blog.sidebar.navAriaLabel',
22
- message: 'Blog recent posts navigation',
23
- description: 'The ARIA label for recent posts in the blog sidebar',
24
- })}>
25
- <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
26
- {sidebar.title}
27
- </div>
28
- <ul className={styles.sidebarItemList}>
29
- {sidebar.items.map((item) => (
30
- <li key={item.permalink} className={styles.sidebarItem}>
31
- <Link
32
- isNavLink
33
- to={item.permalink}
34
- className={styles.sidebarItemLink}
35
- activeClassName={styles.sidebarItemLinkActive}>
36
- {item.title}
37
- </Link>
38
- </li>
39
- ))}
40
- </ul>
41
- </nav>
42
- );
22
+ return <BlogSidebarDesktop sidebar={sidebar} />;
43
23
  }
@@ -15,8 +15,7 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  import SearchMetadata from '../SearchMetadata';
17
17
  import clsx from 'clsx';
18
- export default function BlogTagsListPage(props) {
19
- const {tags, sidebar} = props;
18
+ export default function BlogTagsListPage({tags, sidebar}) {
20
19
  const title = translateTagsPageTitle();
21
20
  return (
22
21
  <HtmlClassNameProvider
@@ -28,7 +27,7 @@ export default function BlogTagsListPage(props) {
28
27
  <SearchMetadata tag="blog_tags_list" />
29
28
  <BlogLayout sidebar={sidebar}>
30
29
  <h1>{title}</h1>
31
- <TagsListByLetter tags={Object.values(tags)} />
30
+ <TagsListByLetter tags={tags} />
32
31
  </BlogLayout>
33
32
  </HtmlClassNameProvider>
34
33
  );
@@ -38,9 +38,7 @@ function useBlogPostsPlural() {
38
38
  );
39
39
  }
40
40
 
41
- export default function BlogTagsPostsPage(props) {
42
- const {metadata, items, sidebar, listMetadata} = props;
43
- const {allTagsPath, name: tagName, count} = metadata;
41
+ export default function BlogTagsPostsPage({tag, items, sidebar, listMetadata}) {
44
42
  const blogPostsPlural = useBlogPostsPlural();
45
43
  const title = translate(
46
44
  {
@@ -49,8 +47,8 @@ export default function BlogTagsPostsPage(props) {
49
47
  message: '{nPosts} tagged with "{tagName}"',
50
48
  },
51
49
  {
52
- nPosts: blogPostsPlural(count),
53
- tagName,
50
+ nPosts: blogPostsPlural(tag.count),
51
+ tagName: tag.label,
54
52
  },
55
53
  );
56
54
  return (
@@ -65,7 +63,7 @@ export default function BlogTagsPostsPage(props) {
65
63
  <header className="margin-bottom--xl">
66
64
  <h1>{title}</h1>
67
65
 
68
- <Link href={allTagsPath}>
66
+ <Link href={tag.allTagsPath}>
69
67
  <Translate
70
68
  id="theme.tags.tagsPageLink"
71
69
  description="The label of the link targeting the tag list page">