@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
@@ -1,19 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateThemeConfig = validateThemeConfig;
7
+ exports.ThemeConfigSchema = void 0;
8
+
9
+ var _utilsValidation = require("@docusaurus/utils-validation");
10
+
1
11
  /**
2
12
  * Copyright (c) Facebook, Inc. and its affiliates.
3
13
  *
4
14
  * This source code is licensed under the MIT license found in the
5
15
  * LICENSE file in the root directory of this source tree.
6
16
  */
7
-
8
- const {Joi, URISchema} = require('@docusaurus/utils-validation');
9
-
10
17
  const DEFAULT_DOCS_CONFIG = {
11
- versionPersistence: 'localStorage',
18
+ versionPersistence: 'localStorage'
12
19
  };
13
- const DocsSchema = Joi.object({
14
- versionPersistence: Joi.string()
15
- .equal('localStorage', 'none')
16
- .default(DEFAULT_DOCS_CONFIG.versionPersistence),
20
+
21
+ const DocsSchema = _utilsValidation.Joi.object({
22
+ versionPersistence: _utilsValidation.Joi.string().equal('localStorage', 'none').default(DEFAULT_DOCS_CONFIG.versionPersistence)
17
23
  }).default(DEFAULT_DOCS_CONFIG);
18
24
 
19
25
  const DEFAULT_COLOR_MODE_CONFIG = {
@@ -24,314 +30,269 @@ const DEFAULT_COLOR_MODE_CONFIG = {
24
30
  darkIcon: '🌜',
25
31
  darkIconStyle: {},
26
32
  lightIcon: '🌞',
27
- lightIconStyle: {},
28
- },
33
+ lightIconStyle: {}
34
+ }
29
35
  };
30
-
31
36
  const DEFAULT_CONFIG = {
32
37
  colorMode: DEFAULT_COLOR_MODE_CONFIG,
33
38
  docs: DEFAULT_DOCS_CONFIG,
34
39
  metadatas: [],
35
40
  prism: {
36
- additionalLanguages: [],
41
+ additionalLanguages: []
37
42
  },
38
43
  navbar: {
39
44
  hideOnScroll: false,
40
- items: [],
45
+ items: []
41
46
  },
42
47
  hideableSidebar: false,
48
+ tableOfContents: {
49
+ minHeadingLevel: 2,
50
+ maxHeadingLevel: 3
51
+ }
43
52
  };
44
53
  exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
45
54
 
46
- const NavbarItemPosition = Joi.string().equal('left', 'right').default('left');
55
+ const NavbarItemPosition = _utilsValidation.Joi.string().equal('left', 'right').default('left');
47
56
 
48
- const NavbarItemBaseSchema = Joi.object({
49
- label: Joi.string(),
50
- className: Joi.string(),
51
- })
52
- // We allow any unknown attributes on the links
53
- // (users may need additional attributes like target, aria-role, data-customAttribute...)
54
- .unknown();
57
+ const NavbarItemBaseSchema = _utilsValidation.Joi.object({
58
+ label: _utilsValidation.Joi.string(),
59
+ className: _utilsValidation.Joi.string()
60
+ }) // We allow any unknown attributes on the links
61
+ // (users may need additional attributes like target, aria-role, data-customAttribute...)
62
+ .unknown();
55
63
 
56
64
  const DefaultNavbarItemSchema = NavbarItemBaseSchema.append({
57
- to: Joi.string(),
58
- href: URISchema,
59
- activeBasePath: Joi.string(),
60
- activeBaseRegex: Joi.string(),
61
- prependBaseUrlToHref: Joi.bool(),
65
+ to: _utilsValidation.Joi.string(),
66
+ href: _utilsValidation.URISchema,
67
+ activeBasePath: _utilsValidation.Joi.string(),
68
+ activeBaseRegex: _utilsValidation.Joi.string(),
69
+ prependBaseUrlToHref: _utilsValidation.Joi.bool(),
62
70
  // This is only triggered in case of a nested dropdown
63
- items: Joi.forbidden().messages({
64
- 'any.unknown': 'Nested dropdowns are not allowed',
65
- }),
66
- })
67
- .xor('href', 'to')
68
- .messages({
69
- 'object.xor': 'One and only one between "to" and "href" should be provided',
70
- });
71
-
71
+ items: _utilsValidation.Joi.forbidden().messages({
72
+ 'any.unknown': 'Nested dropdowns are not allowed'
73
+ })
74
+ }).xor('href', 'to').messages({
75
+ 'object.xor': 'One and only one between "to" and "href" should be provided'
76
+ });
72
77
  const DocsVersionNavbarItemSchema = NavbarItemBaseSchema.append({
73
- type: Joi.string().equal('docsVersion').required(),
74
- to: Joi.string(),
75
- docsPluginId: Joi.string(),
78
+ type: _utilsValidation.Joi.string().equal('docsVersion').required(),
79
+ to: _utilsValidation.Joi.string(),
80
+ docsPluginId: _utilsValidation.Joi.string()
76
81
  });
77
-
78
82
  const DocItemSchema = NavbarItemBaseSchema.append({
79
- type: Joi.string().equal('doc').required(),
80
- docId: Joi.string().required(),
81
- docsPluginId: Joi.string(),
82
- activeSidebarClassName: Joi.string().default('navbar__link--active'),
83
+ type: _utilsValidation.Joi.string().equal('doc').required(),
84
+ docId: _utilsValidation.Joi.string().required(),
85
+ docsPluginId: _utilsValidation.Joi.string()
83
86
  });
84
87
 
85
- const itemWithType = (type) => {
88
+ const itemWithType = type => {
86
89
  // because equal(undefined) is not supported :/
87
- const typeSchema = type
88
- ? Joi.string().required().equal(type)
89
- : Joi.string().forbidden();
90
- return Joi.object({
91
- type: typeSchema,
92
- })
93
- .unknown()
94
- .required();
90
+ const typeSchema = type ? _utilsValidation.Joi.string().required().equal(type) : _utilsValidation.Joi.string().forbidden();
91
+ return _utilsValidation.Joi.object({
92
+ type: typeSchema
93
+ }).unknown().required();
95
94
  };
96
95
 
97
- const DropdownSubitemSchema = Joi.object({
98
- position: Joi.forbidden(),
99
- }).when({
100
- switch: [
101
- {
102
- is: itemWithType('docsVersion'),
103
- then: DocsVersionNavbarItemSchema,
104
- },
105
- {
106
- is: itemWithType('doc'),
107
- then: DocItemSchema,
108
- },
109
- {
110
- is: itemWithType(undefined),
111
- then: DefaultNavbarItemSchema,
112
- },
113
- {
114
- is: Joi.alternatives().try(
115
- itemWithType('dropdown'),
116
- itemWithType('docsVersionDropdown'),
117
- itemWithType('localeDropdown'),
118
- itemWithType('search'),
119
- ),
120
- then: Joi.forbidden().messages({
121
- 'any.unknown': 'Nested dropdowns are not allowed',
122
- }),
123
- },
124
- ],
125
- otherwise: Joi.forbidden().messages({
126
- 'any.unknown': 'Bad navbar item type {.type}',
127
- }),
96
+ const DropdownSubitemSchema = _utilsValidation.Joi.object({
97
+ position: _utilsValidation.Joi.forbidden()
98
+ }).when('.', {
99
+ switch: [{
100
+ is: itemWithType('docsVersion'),
101
+ then: DocsVersionNavbarItemSchema
102
+ }, {
103
+ is: itemWithType('doc'),
104
+ then: DocItemSchema
105
+ }, {
106
+ is: itemWithType(undefined),
107
+ then: DefaultNavbarItemSchema
108
+ }, {
109
+ is: _utilsValidation.Joi.alternatives().try(itemWithType('dropdown'), itemWithType('docsVersionDropdown'), itemWithType('localeDropdown'), itemWithType('search')),
110
+ then: _utilsValidation.Joi.forbidden().messages({
111
+ 'any.unknown': 'Nested dropdowns are not allowed'
112
+ })
113
+ }],
114
+ otherwise: _utilsValidation.Joi.forbidden().messages({
115
+ 'any.unknown': 'Bad navbar item type {.type}'
116
+ })
128
117
  });
129
118
 
130
119
  const DropdownNavbarItemSchema = NavbarItemBaseSchema.append({
131
- items: Joi.array().items(DropdownSubitemSchema).required(),
120
+ items: _utilsValidation.Joi.array().items(DropdownSubitemSchema).required()
132
121
  });
133
-
134
122
  const DocsVersionDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
135
- type: Joi.string().equal('docsVersionDropdown').required(),
136
- docsPluginId: Joi.string(),
137
- dropdownActiveClassDisabled: Joi.boolean(),
138
- dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
139
- dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
123
+ type: _utilsValidation.Joi.string().equal('docsVersionDropdown').required(),
124
+ docsPluginId: _utilsValidation.Joi.string(),
125
+ dropdownActiveClassDisabled: _utilsValidation.Joi.boolean(),
126
+ dropdownItemsBefore: _utilsValidation.Joi.array().items(DropdownSubitemSchema).default([]),
127
+ dropdownItemsAfter: _utilsValidation.Joi.array().items(DropdownSubitemSchema).default([])
140
128
  });
141
-
142
129
  const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
143
- type: Joi.string().equal('localeDropdown').required(),
144
- dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
145
- dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
130
+ type: _utilsValidation.Joi.string().equal('localeDropdown').required(),
131
+ dropdownItemsBefore: _utilsValidation.Joi.array().items(DropdownSubitemSchema).default([]),
132
+ dropdownItemsAfter: _utilsValidation.Joi.array().items(DropdownSubitemSchema).default([])
146
133
  });
147
134
 
148
- const SearchItemSchema = Joi.object({
149
- type: Joi.string().equal('search').required(),
135
+ const SearchItemSchema = _utilsValidation.Joi.object({
136
+ type: _utilsValidation.Joi.string().equal('search').required()
150
137
  });
151
138
 
152
- const NavbarItemSchema = Joi.object({
153
- position: NavbarItemPosition,
154
- }).when({
155
- switch: [
156
- {
157
- is: itemWithType('docsVersion'),
158
- then: DocsVersionNavbarItemSchema,
159
- },
160
- {
161
- is: itemWithType('dropdown'),
139
+ const NavbarItemSchema = _utilsValidation.Joi.object({
140
+ position: NavbarItemPosition
141
+ }).when('.', {
142
+ switch: [{
143
+ is: itemWithType('docsVersion'),
144
+ then: DocsVersionNavbarItemSchema
145
+ }, {
146
+ is: itemWithType('dropdown'),
147
+ then: DropdownNavbarItemSchema
148
+ }, {
149
+ is: itemWithType('docsVersionDropdown'),
150
+ then: DocsVersionDropdownNavbarItemSchema
151
+ }, {
152
+ is: itemWithType('doc'),
153
+ then: DocItemSchema
154
+ }, {
155
+ is: itemWithType('localeDropdown'),
156
+ then: LocaleDropdownNavbarItemSchema
157
+ }, {
158
+ is: itemWithType('search'),
159
+ then: SearchItemSchema
160
+ }, {
161
+ is: itemWithType(undefined),
162
+ then: _utilsValidation.Joi.object().when('.', {
163
+ // Dropdown item can be specified without type field
164
+ is: _utilsValidation.Joi.object({
165
+ items: _utilsValidation.Joi.array().required()
166
+ }).unknown(),
162
167
  then: DropdownNavbarItemSchema,
163
- },
164
- {
165
- is: itemWithType('docsVersionDropdown'),
166
- then: DocsVersionDropdownNavbarItemSchema,
167
- },
168
- {
169
- is: itemWithType('doc'),
170
- then: DocItemSchema,
171
- },
172
- {
173
- is: itemWithType('localeDropdown'),
174
- then: LocaleDropdownNavbarItemSchema,
175
- },
176
- {
177
- is: itemWithType('search'),
178
- then: SearchItemSchema,
179
- },
180
- {
181
- is: itemWithType(undefined),
182
- then: Joi.object().when({
183
- // Dropdown item can be specified without type field
184
- is: Joi.object({
185
- items: Joi.array().required(),
186
- }).unknown(),
187
- then: DropdownNavbarItemSchema,
188
- otherwise: DefaultNavbarItemSchema,
189
- }),
190
- },
191
- ],
192
- otherwise: Joi.forbidden().messages({
193
- 'any.unknown': 'Bad navbar item type {.type}',
194
- }),
168
+ otherwise: DefaultNavbarItemSchema
169
+ })
170
+ }],
171
+ otherwise: _utilsValidation.Joi.forbidden().messages({
172
+ 'any.unknown': 'Bad navbar item type {.type}'
173
+ })
195
174
  });
196
175
 
197
- const ColorModeSchema = Joi.object({
198
- defaultMode: Joi.string()
199
- .equal('dark', 'light')
200
- .default(DEFAULT_COLOR_MODE_CONFIG.defaultMode),
201
- disableSwitch: Joi.bool().default(DEFAULT_COLOR_MODE_CONFIG.disableSwitch),
202
- respectPrefersColorScheme: Joi.bool().default(
203
- DEFAULT_COLOR_MODE_CONFIG.respectPrefersColorScheme,
204
- ),
205
- switchConfig: Joi.object({
206
- darkIcon: Joi.string().default(
207
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIcon,
208
- ),
209
- darkIconStyle: Joi.object().default(
210
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIconStyle,
211
- ),
212
- lightIcon: Joi.string().default(
213
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIcon,
214
- ),
215
- lightIconStyle: Joi.object().default(
216
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIconStyle,
217
- ),
218
- }).default(DEFAULT_COLOR_MODE_CONFIG.switchConfig),
219
- }).default(DEFAULT_COLOR_MODE_CONFIG);
176
+ const ColorModeSchema = _utilsValidation.Joi.object({
177
+ defaultMode: _utilsValidation.Joi.string().equal('dark', 'light').default(DEFAULT_COLOR_MODE_CONFIG.defaultMode),
178
+ disableSwitch: _utilsValidation.Joi.bool().default(DEFAULT_COLOR_MODE_CONFIG.disableSwitch),
179
+ respectPrefersColorScheme: _utilsValidation.Joi.bool().default(DEFAULT_COLOR_MODE_CONFIG.respectPrefersColorScheme),
180
+ switchConfig: _utilsValidation.Joi.object({
181
+ darkIcon: _utilsValidation.Joi.string().default(DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIcon),
182
+ darkIconStyle: _utilsValidation.Joi.object().default(DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIconStyle),
183
+ lightIcon: _utilsValidation.Joi.string().default(DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIcon),
184
+ lightIconStyle: _utilsValidation.Joi.object().default(DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIconStyle)
185
+ }).default(DEFAULT_COLOR_MODE_CONFIG.switchConfig)
186
+ }).default(DEFAULT_COLOR_MODE_CONFIG); // schema can probably be improved
220
187
 
221
- // schema can probably be improved
222
- const HtmlMetadataSchema = Joi.object({
223
- id: Joi.string(),
224
- name: Joi.string(),
225
- property: Joi.string(),
226
- content: Joi.string(),
227
- itemprop: Joi.string(),
188
+
189
+ const HtmlMetadataSchema = _utilsValidation.Joi.object({
190
+ id: _utilsValidation.Joi.string(),
191
+ name: _utilsValidation.Joi.string(),
192
+ property: _utilsValidation.Joi.string(),
193
+ content: _utilsValidation.Joi.string(),
194
+ itemprop: _utilsValidation.Joi.string()
228
195
  }).unknown();
229
196
 
230
- const FooterLinkItemSchema = Joi.object({
231
- to: Joi.string(),
232
- href: URISchema,
233
- html: Joi.string(),
234
- label: Joi.string(),
235
- })
236
- .xor('to', 'href', 'html')
237
- .with('to', 'label')
238
- .with('href', 'label')
239
- .nand('html', 'label')
240
- // We allow any unknown attributes on the links
241
- // (users may need additional attributes like target, aria-role, data-customAttribute...)
242
- .unknown();
197
+ const FooterLinkItemSchema = _utilsValidation.Joi.object({
198
+ to: _utilsValidation.Joi.string(),
199
+ href: _utilsValidation.URISchema,
200
+ html: _utilsValidation.Joi.string(),
201
+ label: _utilsValidation.Joi.string()
202
+ }).xor('to', 'href', 'html').with('to', 'label').with('href', 'label').nand('html', 'label') // We allow any unknown attributes on the links
203
+ // (users may need additional attributes like target, aria-role, data-customAttribute...)
204
+ .unknown();
243
205
 
244
- const CustomCssSchema = Joi.alternatives()
245
- .try(Joi.array().items(Joi.string().required()), Joi.string().required())
246
- .optional();
206
+ const CustomCssSchema = _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array().items(_utilsValidation.Joi.string().required()), _utilsValidation.Joi.string().required()).optional();
247
207
 
248
- const ThemeConfigSchema = Joi.object({
208
+ const ThemeConfigSchema = _utilsValidation.Joi.object({
249
209
  // TODO temporary (@alpha-58)
250
- disableDarkMode: Joi.any().forbidden(false).messages({
251
- 'any.unknown':
252
- 'disableDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.disableSwitch = true',
210
+ disableDarkMode: _utilsValidation.Joi.any().forbidden().messages({
211
+ 'any.unknown': 'disableDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.disableSwitch = true'
253
212
  }),
254
213
  // TODO temporary (@alpha-58)
255
- defaultDarkMode: Joi.any().forbidden(false).messages({
256
- 'any.unknown':
257
- 'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
214
+ defaultDarkMode: _utilsValidation.Joi.any().forbidden().messages({
215
+ 'any.unknown': 'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"'
258
216
  }),
259
217
  customCss: CustomCssSchema,
260
218
  colorMode: ColorModeSchema,
261
- image: Joi.string(),
219
+ image: _utilsValidation.Joi.string(),
262
220
  docs: DocsSchema,
263
- metadatas: Joi.array()
264
- .items(HtmlMetadataSchema)
265
- .default(DEFAULT_CONFIG.metadatas),
266
- announcementBar: Joi.object({
267
- id: Joi.string().default('announcement-bar'),
268
- content: Joi.string(),
269
- backgroundColor: Joi.string(),
270
- textColor: Joi.string(),
271
- isCloseable: Joi.bool().default(true),
221
+ metadatas: _utilsValidation.Joi.array().items(HtmlMetadataSchema).default(DEFAULT_CONFIG.metadatas),
222
+ announcementBar: _utilsValidation.Joi.object({
223
+ id: _utilsValidation.Joi.string().default('announcement-bar'),
224
+ content: _utilsValidation.Joi.string().required(),
225
+ backgroundColor: _utilsValidation.Joi.string(),
226
+ textColor: _utilsValidation.Joi.string(),
227
+ isCloseable: _utilsValidation.Joi.bool().default(true)
272
228
  }).optional(),
273
- navbar: Joi.object({
274
- style: Joi.string().equal('dark', 'primary'),
275
- hideOnScroll: Joi.bool().default(DEFAULT_CONFIG.navbar.hideOnScroll),
229
+ navbar: _utilsValidation.Joi.object({
230
+ style: _utilsValidation.Joi.string().equal('dark', 'primary'),
231
+ hideOnScroll: _utilsValidation.Joi.bool().default(DEFAULT_CONFIG.navbar.hideOnScroll),
276
232
  // TODO temporary (@alpha-58)
277
- links: Joi.any().forbidden().messages({
278
- 'any.unknown':
279
- 'themeConfig.navbar.links has been renamed as themeConfig.navbar.items',
280
- }),
281
- items: Joi.array()
282
- .items(NavbarItemSchema)
283
- .default(DEFAULT_CONFIG.navbar.items),
284
- title: Joi.string().allow('', null),
285
- logo: Joi.object({
286
- alt: Joi.string().allow(''),
287
- src: Joi.string().required(),
288
- srcDark: Joi.string(),
289
- href: Joi.string(),
290
- target: Joi.string(),
233
+ links: _utilsValidation.Joi.any().forbidden().messages({
234
+ 'any.unknown': 'themeConfig.navbar.links has been renamed as themeConfig.navbar.items'
291
235
  }),
236
+ items: _utilsValidation.Joi.array().items(NavbarItemSchema).default(DEFAULT_CONFIG.navbar.items),
237
+ title: _utilsValidation.Joi.string().allow('', null),
238
+ logo: _utilsValidation.Joi.object({
239
+ alt: _utilsValidation.Joi.string().allow(''),
240
+ src: _utilsValidation.Joi.string().required(),
241
+ srcDark: _utilsValidation.Joi.string(),
242
+ width: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.string(), _utilsValidation.Joi.number()),
243
+ height: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.string(), _utilsValidation.Joi.number()),
244
+ href: _utilsValidation.Joi.string(),
245
+ target: _utilsValidation.Joi.string()
246
+ })
292
247
  }).default(DEFAULT_CONFIG.navbar),
293
- footer: Joi.object({
294
- style: Joi.string().equal('dark', 'light').default('light'),
295
- logo: Joi.object({
296
- alt: Joi.string().allow(''),
297
- src: Joi.string(),
298
- srcDark: Joi.string(),
299
- href: Joi.string(),
248
+ footer: _utilsValidation.Joi.object({
249
+ style: _utilsValidation.Joi.string().equal('dark', 'light').default('light'),
250
+ logo: _utilsValidation.Joi.object({
251
+ alt: _utilsValidation.Joi.string().allow(''),
252
+ src: _utilsValidation.Joi.string(),
253
+ srcDark: _utilsValidation.Joi.string(),
254
+ // TODO infer this from reading the image
255
+ width: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.string(), _utilsValidation.Joi.number()),
256
+ height: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.string(), _utilsValidation.Joi.number()),
257
+ href: _utilsValidation.Joi.string()
300
258
  }),
301
- copyright: Joi.string(),
302
- links: Joi.array()
303
- .items(
304
- Joi.object({
305
- title: Joi.string().allow(null),
306
- items: Joi.array().items(FooterLinkItemSchema).default([]),
307
- }),
308
- )
309
- .default([]),
259
+ copyright: _utilsValidation.Joi.string(),
260
+ links: _utilsValidation.Joi.array().items(_utilsValidation.Joi.object({
261
+ title: _utilsValidation.Joi.string().allow(null),
262
+ items: _utilsValidation.Joi.array().items(FooterLinkItemSchema).default([])
263
+ })).default([])
310
264
  }).optional(),
311
- prism: Joi.object({
312
- theme: Joi.object({
313
- plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
314
- styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
265
+ prism: _utilsValidation.Joi.object({
266
+ theme: _utilsValidation.Joi.object({
267
+ plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
268
+ styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
315
269
  }),
316
- darkTheme: Joi.object({
317
- plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
318
- styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
270
+ darkTheme: _utilsValidation.Joi.object({
271
+ plain: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required(),
272
+ styles: _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array(), _utilsValidation.Joi.object()).required()
319
273
  }),
320
- defaultLanguage: Joi.string(),
321
- additionalLanguages: Joi.array()
322
- .items(Joi.string())
323
- .default(DEFAULT_CONFIG.prism.additionalLanguages),
324
- })
325
- .default(DEFAULT_CONFIG.prism)
326
- .unknown(),
327
- hideableSidebar: Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
328
- sidebarCollapsible: Joi.forbidden().messages({
329
- 'any.unknown':
330
- 'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs',
274
+ defaultLanguage: _utilsValidation.Joi.string(),
275
+ additionalLanguages: _utilsValidation.Joi.array().items(_utilsValidation.Joi.string()).default(DEFAULT_CONFIG.prism.additionalLanguages)
276
+ }).default(DEFAULT_CONFIG.prism).unknown(),
277
+ hideableSidebar: _utilsValidation.Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
278
+ sidebarCollapsible: _utilsValidation.Joi.forbidden().messages({
279
+ 'any.unknown': 'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs'
331
280
  }),
281
+ tableOfContents: _utilsValidation.Joi.object({
282
+ minHeadingLevel: _utilsValidation.Joi.number().default(DEFAULT_CONFIG.tableOfContents.minHeadingLevel).when('maxHeadingLevel', {
283
+ is: _utilsValidation.Joi.exist(),
284
+ then: _utilsValidation.Joi.number().integer().min(2).max(6).max(_utilsValidation.Joi.ref('maxHeadingLevel')),
285
+ otherwise: _utilsValidation.Joi.number().integer().min(2).max(6)
286
+ }),
287
+ maxHeadingLevel: _utilsValidation.Joi.number().integer().min(2).max(6).default(DEFAULT_CONFIG.tableOfContents.maxHeadingLevel)
288
+ }).default(DEFAULT_CONFIG.tableOfContents)
332
289
  });
290
+
333
291
  exports.ThemeConfigSchema = ThemeConfigSchema;
334
292
 
335
- exports.validateThemeConfig = ({validate, themeConfig}) => {
293
+ function validateThemeConfig({
294
+ validate,
295
+ themeConfig
296
+ }) {
336
297
  return validate(ThemeConfigSchema, themeConfig);
337
- };
298
+ }