@docusaurus/theme-classic 0.0.0-4281 → 0.0.0-4282

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 (147) hide show
  1. package/lib/theme-classic.d.ts +3 -1
  2. package/package.json +12 -12
  3. package/src/index.ts +2 -5
  4. package/src/theme-classic.d.ts +3 -1
  5. package/babel.config.js +0 -35
  6. package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  7. package/lib/__tests__/translations.test.js +0 -112
  8. package/lib/__tests__/validateThemeConfig.test.js +0 -607
  9. package/lib/theme/AnnouncementBar/index.js +0 -68
  10. package/lib/theme/AnnouncementBar/styles.module.css +0 -63
  11. package/lib/theme/BackToTopButton/index.js +0 -140
  12. package/lib/theme/BackToTopButton/styles.module.css +0 -42
  13. package/lib/theme/BlogArchivePage/index.js +0 -89
  14. package/lib/theme/BlogLayout/index.js +0 -51
  15. package/lib/theme/BlogListPage/index.js +0 -60
  16. package/lib/theme/BlogListPaginator/index.js +0 -63
  17. package/lib/theme/BlogPostAuthor/index.js +0 -51
  18. package/lib/theme/BlogPostAuthor/styles.module.css +0 -12
  19. package/lib/theme/BlogPostAuthors/index.js +0 -47
  20. package/lib/theme/BlogPostAuthors/styles.module.css +0 -11
  21. package/lib/theme/BlogPostItem/index.js +0 -152
  22. package/lib/theme/BlogPostItem/styles.module.css +0 -18
  23. package/lib/theme/BlogPostPage/index.js +0 -82
  24. package/lib/theme/BlogPostPaginator/index.js +0 -64
  25. package/lib/theme/BlogSidebar/index.js +0 -49
  26. package/lib/theme/BlogSidebar/styles.module.css +0 -44
  27. package/lib/theme/BlogTagsListPage/index.js +0 -40
  28. package/lib/theme/BlogTagsPostsPage/index.js +0 -86
  29. package/lib/theme/CodeBlock/index.js +0 -133
  30. package/lib/theme/CodeBlock/styles.module.css +0 -65
  31. package/lib/theme/Details/index.js +0 -30
  32. package/lib/theme/Details/styles.module.css +0 -13
  33. package/lib/theme/DocCard/index.js +0 -84
  34. package/lib/theme/DocCard/styles.module.css +0 -43
  35. package/lib/theme/DocCardList/index.js +0 -28
  36. package/lib/theme/DocCategoryGeneratedIndexPage/index.js +0 -57
  37. package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +0 -18
  38. package/lib/theme/DocItem/index.js +0 -112
  39. package/lib/theme/DocItem/styles.module.css +0 -22
  40. package/lib/theme/DocItemFooter/index.js +0 -79
  41. package/lib/theme/DocItemFooter/styles.module.css +0 -18
  42. package/lib/theme/DocPage/index.js +0 -154
  43. package/lib/theme/DocPage/styles.module.css +0 -85
  44. package/lib/theme/DocPaginator/index.js +0 -62
  45. package/lib/theme/DocSidebar/index.js +0 -134
  46. package/lib/theme/DocSidebar/styles.module.css +0 -106
  47. package/lib/theme/DocSidebarItem/index.js +0 -209
  48. package/lib/theme/DocSidebarItem/styles.module.css +0 -19
  49. package/lib/theme/DocTagDocListPage/index.js +0 -89
  50. package/lib/theme/DocTagsListPage/index.js +0 -44
  51. package/lib/theme/DocVersionBadge/index.js +0 -34
  52. package/lib/theme/DocVersionBanner/index.js +0 -130
  53. package/lib/theme/EditThisPage/index.js +0 -33
  54. package/lib/theme/ErrorPageContent.js +0 -43
  55. package/lib/theme/Footer/index.js +0 -119
  56. package/lib/theme/Footer/styles.module.css +0 -15
  57. package/lib/theme/Heading/index.js +0 -71
  58. package/lib/theme/Heading/styles.css +0 -22
  59. package/lib/theme/Heading/styles.module.css +0 -19
  60. package/lib/theme/IconArrow/index.js +0 -28
  61. package/lib/theme/IconClose/index.js +0 -31
  62. package/lib/theme/IconEdit/index.js +0 -34
  63. package/lib/theme/IconEdit/styles.module.css +0 -11
  64. package/lib/theme/IconExternalLink/index.js +0 -30
  65. package/lib/theme/IconExternalLink/styles.module.css +0 -12
  66. package/lib/theme/IconLanguage/index.js +0 -29
  67. package/lib/theme/IconMenu/index.js +0 -30
  68. package/lib/theme/LastUpdated/index.js +0 -63
  69. package/lib/theme/Layout/index.js +0 -68
  70. package/lib/theme/Layout/styles.css +0 -27
  71. package/lib/theme/LayoutHead/index.js +0 -149
  72. package/lib/theme/LayoutProviders/index.js +0 -40
  73. package/lib/theme/Logo/index.js +0 -62
  74. package/lib/theme/MDXComponents/index.js +0 -106
  75. package/lib/theme/MDXComponents/styles.css +0 -11
  76. package/lib/theme/MDXPage/index.js +0 -67
  77. package/lib/theme/MDXPage/styles.module.css +0 -10
  78. package/lib/theme/Navbar/index.js +0 -267
  79. package/lib/theme/Navbar/styles.module.css +0 -27
  80. package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -113
  81. package/lib/theme/NavbarItem/DocNavbarItem.js +0 -62
  82. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -83
  83. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
  84. package/lib/theme/NavbarItem/DropdownNavbarItem.js +0 -154
  85. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +0 -68
  86. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +0 -11
  87. package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
  88. package/lib/theme/NavbarItem/index.js +0 -74
  89. package/lib/theme/NotFound.js +0 -57
  90. package/lib/theme/SearchBar.js +0 -15
  91. package/lib/theme/SearchMetadata/index.js +0 -33
  92. package/lib/theme/Seo/index.js +0 -52
  93. package/lib/theme/SkipToContent/index.js +0 -71
  94. package/lib/theme/SkipToContent/styles.module.css +0 -14
  95. package/lib/theme/TOC/index.js +0 -39
  96. package/lib/theme/TOC/styles.module.css +0 -23
  97. package/lib/theme/TOCCollapsible/index.js +0 -53
  98. package/lib/theme/TOCCollapsible/styles.module.css +0 -50
  99. package/lib/theme/TOCInline/index.js +0 -33
  100. package/lib/theme/TOCInline/styles.module.css +0 -12
  101. package/lib/theme/TOCItems/index.js +0 -78
  102. package/lib/theme/TabItem/index.js +0 -32
  103. package/lib/theme/Tabs/__tests__/index.test.js +0 -123
  104. package/lib/theme/Tabs/index.js +0 -173
  105. package/lib/theme/Tabs/styles.module.css +0 -10
  106. package/lib/theme/Tag/index.js +0 -40
  107. package/lib/theme/Tag/styles.module.css +0 -70
  108. package/lib/theme/TagsListByLetter/index.js +0 -48
  109. package/lib/theme/TagsListByLetter/styles.module.css +0 -11
  110. package/lib/theme/TagsListInline/index.js +0 -44
  111. package/lib/theme/TagsListInline/styles.module.css +0 -15
  112. package/lib/theme/ThemeContext.js +0 -21
  113. package/lib/theme/ThemeProvider/index.js +0 -43
  114. package/lib/theme/ThemedImage/index.js +0 -47
  115. package/lib/theme/ThemedImage/styles.module.css +0 -18
  116. package/lib/theme/Toggle/index.js +0 -91
  117. package/lib/theme/Toggle/styles.module.css +0 -105
  118. package/lib/theme/UserPreferencesContext.js +0 -18
  119. package/lib/theme/UserPreferencesProvider/index.js +0 -41
  120. package/lib/theme/hooks/styles.css +0 -10
  121. package/lib/theme/hooks/useDocs.js +0 -18
  122. package/lib/theme/hooks/useHideableNavbar.js +0 -74
  123. package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
  124. package/lib/theme/hooks/useLockBodyScroll.js +0 -26
  125. package/lib/theme/hooks/usePrismTheme.js +0 -36
  126. package/lib/theme/hooks/useTabGroupChoice.js +0 -51
  127. package/lib/theme/hooks/useTheme.js +0 -97
  128. package/lib/theme/hooks/useThemeContext.js +0 -31
  129. package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
  130. package/lib/theme/hooks/useWindowSize.js +0 -68
  131. package/lib/theme/prism-include-languages.js +0 -40
  132. package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  133. package/lib-next/__tests__/translations.test.js +0 -128
  134. package/lib-next/__tests__/validateThemeConfig.test.js +0 -607
  135. package/lib-next/admonitions.css +0 -35
  136. package/lib-next/deps.d.ts +0 -13
  137. package/lib-next/index.js +0 -227
  138. package/lib-next/prism-include-languages.js +0 -9
  139. package/lib-next/theme-classic.d.ts +0 -794
  140. package/lib-next/translations.js +0 -141
  141. package/lib-next/types.d.ts +0 -11
  142. package/lib-next/validateThemeConfig.js +0 -344
  143. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  144. package/src/__tests__/translations.test.ts +0 -116
  145. package/src/__tests__/validateThemeConfig.test.js +0 -607
  146. package/src/theme/Tabs/__tests__/index.test.tsx +0 -129
  147. package/tsconfig.json +0 -11
@@ -1,141 +0,0 @@
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 {keyBy, chain} from 'lodash';
8
- import {mergeTranslations} from '@docusaurus/utils';
9
-
10
- function getNavbarTranslationFile(navbar) {
11
- // TODO handle properly all the navbar item types here!
12
- function flattenNavbarItems(items) {
13
- const subItems = items.flatMap((item) => {
14
- const allSubItems = [item.items ?? []].flat();
15
- return flattenNavbarItems(allSubItems);
16
- });
17
- return [...items, ...subItems];
18
- }
19
-
20
- const allNavbarItems = flattenNavbarItems(navbar.items);
21
- const navbarItemsTranslations = chain(
22
- allNavbarItems.filter((navbarItem) => !!navbarItem.label),
23
- )
24
- .keyBy((navbarItem) => `item.label.${navbarItem.label}`)
25
- .mapValues((navbarItem) => ({
26
- message: navbarItem.label,
27
- description: `Navbar item with label ${navbarItem.label}`,
28
- }))
29
- .value();
30
- const titleTranslations = navbar.title
31
- ? {
32
- title: {
33
- message: navbar.title,
34
- description: 'The title in the navbar',
35
- },
36
- }
37
- : {};
38
- return mergeTranslations([titleTranslations, navbarItemsTranslations]);
39
- }
40
-
41
- function translateNavbar(navbar, navbarTranslations) {
42
- return {
43
- ...navbar,
44
- title: navbarTranslations.title?.message ?? navbar.title,
45
- // TODO handle properly all the navbar item types here!
46
- items: navbar.items.map((item) => {
47
- const subItems = item.items?.map((subItem) => ({
48
- ...subItem,
49
- label:
50
- navbarTranslations[`item.label.${subItem.label}`]?.message ??
51
- subItem.label,
52
- }));
53
- return {
54
- ...item,
55
- label:
56
- navbarTranslations[`item.label.${item.label}`]?.message ?? item.label,
57
- ...(subItems
58
- ? {
59
- items: subItems,
60
- }
61
- : undefined),
62
- };
63
- }),
64
- };
65
- }
66
-
67
- function getFooterTranslationFile(footer) {
68
- // TODO POC code
69
- const footerLinkTitles = chain(footer.links.filter((link) => !!link.title))
70
- .keyBy((link) => `link.title.${link.title}`)
71
- .mapValues((link) => ({
72
- message: link.title,
73
- description: `The title of the footer links column with title=${link.title} in the footer`,
74
- }))
75
- .value();
76
- const footerLinkLabels = chain(
77
- footer.links.flatMap((link) => link.items).filter((link) => !!link.label),
78
- )
79
- .keyBy((linkItem) => `link.item.label.${linkItem.label}`)
80
- .mapValues((linkItem) => ({
81
- message: linkItem.label,
82
- description: `The label of footer link with label=${
83
- linkItem.label
84
- } linking to ${linkItem.to ?? linkItem.href}`,
85
- }))
86
- .value();
87
- const copyright = footer.copyright
88
- ? {
89
- copyright: {
90
- message: footer.copyright,
91
- description: 'The footer copyright',
92
- },
93
- }
94
- : {};
95
- return mergeTranslations([footerLinkTitles, footerLinkLabels, copyright]);
96
- }
97
-
98
- function translateFooter(footer, footerTranslations) {
99
- const links = footer.links.map((link) => ({
100
- ...link,
101
- title:
102
- footerTranslations[`link.title.${link.title}`]?.message ?? link.title,
103
- items: link.items.map((linkItem) => ({
104
- ...linkItem,
105
- label:
106
- footerTranslations[`link.item.label.${linkItem.label}`]?.message ??
107
- linkItem.label,
108
- })),
109
- }));
110
- const copyright = footerTranslations.copyright?.message ?? footer.copyright;
111
- return {...footer, links, copyright};
112
- }
113
-
114
- export function getTranslationFiles({themeConfig}) {
115
- const translationFiles = [
116
- {
117
- path: 'navbar',
118
- content: getNavbarTranslationFile(themeConfig.navbar),
119
- },
120
- themeConfig.footer
121
- ? {
122
- path: 'footer',
123
- content: getFooterTranslationFile(themeConfig.footer),
124
- }
125
- : undefined,
126
- ];
127
- return translationFiles.filter(Boolean);
128
- }
129
- export function translateThemeConfig({themeConfig, translationFiles}) {
130
- const translationFilesMap = keyBy(translationFiles, (f) => f.path);
131
- return {
132
- ...themeConfig,
133
- navbar: translateNavbar(
134
- themeConfig.navbar,
135
- translationFilesMap.navbar.content,
136
- ),
137
- footer: themeConfig.footer
138
- ? translateFooter(themeConfig.footer, translationFilesMap.footer.content)
139
- : undefined,
140
- };
141
- }
@@ -1,11 +0,0 @@
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
- /// <reference types="@docusaurus/module-type-aliases" />
9
- /// <reference types="@docusaurus/plugin-content-blog" />
10
- /// <reference types="@docusaurus/plugin-content-docs" />
11
- /// <reference types="@docusaurus/plugin-content-pages" />
@@ -1,344 +0,0 @@
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 {Joi, URISchema} from '@docusaurus/utils-validation';
8
- const DEFAULT_DOCS_CONFIG = {
9
- versionPersistence: 'localStorage',
10
- };
11
- const DocsSchema = Joi.object({
12
- versionPersistence: Joi.string()
13
- .equal('localStorage', 'none')
14
- .default(DEFAULT_DOCS_CONFIG.versionPersistence),
15
- }).default(DEFAULT_DOCS_CONFIG);
16
- const DEFAULT_COLOR_MODE_CONFIG = {
17
- defaultMode: 'light',
18
- disableSwitch: false,
19
- respectPrefersColorScheme: false,
20
- switchConfig: {
21
- darkIcon: '🌜',
22
- darkIconStyle: {},
23
- lightIcon: '🌞',
24
- lightIconStyle: {},
25
- },
26
- };
27
- const DEFAULT_CONFIG = {
28
- colorMode: DEFAULT_COLOR_MODE_CONFIG,
29
- docs: DEFAULT_DOCS_CONFIG,
30
- metadata: [],
31
- prism: {
32
- additionalLanguages: [],
33
- },
34
- navbar: {
35
- hideOnScroll: false,
36
- items: [],
37
- },
38
- hideableSidebar: false,
39
- tableOfContents: {
40
- minHeadingLevel: 2,
41
- maxHeadingLevel: 3,
42
- },
43
- };
44
- const NavbarItemPosition = Joi.string().equal('left', 'right').default('left');
45
- const NavbarItemBaseSchema = Joi.object({
46
- label: Joi.string(),
47
- className: Joi.string(),
48
- }) // We allow any unknown attributes on the links
49
- // (users may need additional attributes like target, aria-role, data-customAttribute...)
50
- .unknown();
51
- const DefaultNavbarItemSchema = NavbarItemBaseSchema.append({
52
- to: Joi.string(),
53
- href: URISchema,
54
- activeBasePath: Joi.string(),
55
- activeBaseRegex: Joi.string(),
56
- prependBaseUrlToHref: Joi.bool(),
57
- // This is only triggered in case of a nested dropdown
58
- items: Joi.forbidden().messages({
59
- 'any.unknown': 'Nested dropdowns are not allowed',
60
- }),
61
- })
62
- .xor('href', 'to')
63
- .messages({
64
- 'object.xor': 'One and only one between "to" and "href" should be provided',
65
- });
66
- const DocsVersionNavbarItemSchema = NavbarItemBaseSchema.append({
67
- type: Joi.string().equal('docsVersion').required(),
68
- to: Joi.string(),
69
- docsPluginId: Joi.string(),
70
- });
71
- const DocItemSchema = NavbarItemBaseSchema.append({
72
- type: Joi.string().equal('doc').required(),
73
- docId: Joi.string().required(),
74
- docsPluginId: Joi.string(),
75
- });
76
-
77
- const itemWithType = (type) => {
78
- // because equal(undefined) is not supported :/
79
- const typeSchema = type
80
- ? Joi.string().required().equal(type)
81
- : Joi.string().forbidden();
82
- return Joi.object({
83
- type: typeSchema,
84
- })
85
- .unknown()
86
- .required();
87
- };
88
-
89
- const DropdownSubitemSchema = Joi.object({
90
- position: Joi.forbidden(),
91
- }).when('.', {
92
- switch: [
93
- {
94
- is: itemWithType('docsVersion'),
95
- then: DocsVersionNavbarItemSchema,
96
- },
97
- {
98
- is: itemWithType('doc'),
99
- then: DocItemSchema,
100
- },
101
- {
102
- is: itemWithType(undefined),
103
- then: DefaultNavbarItemSchema,
104
- },
105
- {
106
- is: Joi.alternatives().try(
107
- itemWithType('dropdown'),
108
- itemWithType('docsVersionDropdown'),
109
- itemWithType('localeDropdown'),
110
- itemWithType('search'),
111
- ),
112
- then: Joi.forbidden().messages({
113
- 'any.unknown': 'Nested dropdowns are not allowed',
114
- }),
115
- },
116
- ],
117
- otherwise: Joi.forbidden().messages({
118
- 'any.unknown': 'Bad navbar item type {.type}',
119
- }),
120
- });
121
- const DropdownNavbarItemSchema = NavbarItemBaseSchema.append({
122
- items: Joi.array().items(DropdownSubitemSchema).required(),
123
- });
124
- const DocsVersionDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
125
- type: Joi.string().equal('docsVersionDropdown').required(),
126
- docsPluginId: Joi.string(),
127
- dropdownActiveClassDisabled: Joi.boolean(),
128
- dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
129
- dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
130
- });
131
- const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
132
- type: Joi.string().equal('localeDropdown').required(),
133
- dropdownItemsBefore: Joi.array().items(DropdownSubitemSchema).default([]),
134
- dropdownItemsAfter: Joi.array().items(DropdownSubitemSchema).default([]),
135
- });
136
- const SearchItemSchema = Joi.object({
137
- type: Joi.string().equal('search').required(),
138
- });
139
- const NavbarItemSchema = Joi.object({
140
- position: NavbarItemPosition,
141
- }).when('.', {
142
- switch: [
143
- {
144
- is: itemWithType('docsVersion'),
145
- then: DocsVersionNavbarItemSchema,
146
- },
147
- {
148
- is: itemWithType('dropdown'),
149
- then: DropdownNavbarItemSchema,
150
- },
151
- {
152
- is: itemWithType('docsVersionDropdown'),
153
- then: DocsVersionDropdownNavbarItemSchema,
154
- },
155
- {
156
- is: itemWithType('doc'),
157
- then: DocItemSchema,
158
- },
159
- {
160
- is: itemWithType('localeDropdown'),
161
- then: LocaleDropdownNavbarItemSchema,
162
- },
163
- {
164
- is: itemWithType('search'),
165
- then: SearchItemSchema,
166
- },
167
- {
168
- is: itemWithType(undefined),
169
- then: Joi.object().when('.', {
170
- // Dropdown item can be specified without type field
171
- is: Joi.object({
172
- items: Joi.array().required(),
173
- }).unknown(),
174
- then: DropdownNavbarItemSchema,
175
- otherwise: DefaultNavbarItemSchema,
176
- }),
177
- },
178
- ],
179
- otherwise: Joi.forbidden().messages({
180
- 'any.unknown': 'Bad navbar item type {.type}',
181
- }),
182
- });
183
- const ColorModeSchema = Joi.object({
184
- defaultMode: Joi.string()
185
- .equal('dark', 'light')
186
- .default(DEFAULT_COLOR_MODE_CONFIG.defaultMode),
187
- disableSwitch: Joi.bool().default(DEFAULT_COLOR_MODE_CONFIG.disableSwitch),
188
- respectPrefersColorScheme: Joi.bool().default(
189
- DEFAULT_COLOR_MODE_CONFIG.respectPrefersColorScheme,
190
- ),
191
- switchConfig: Joi.object({
192
- darkIcon: Joi.string().default(
193
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIcon,
194
- ),
195
- darkIconStyle: Joi.object().default(
196
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.darkIconStyle,
197
- ),
198
- lightIcon: Joi.string().default(
199
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIcon,
200
- ),
201
- lightIconStyle: Joi.object().default(
202
- DEFAULT_COLOR_MODE_CONFIG.switchConfig.lightIconStyle,
203
- ),
204
- }).default(DEFAULT_COLOR_MODE_CONFIG.switchConfig),
205
- }).default(DEFAULT_COLOR_MODE_CONFIG); // schema can probably be improved
206
-
207
- const HtmlMetadataSchema = Joi.object({
208
- id: Joi.string(),
209
- name: Joi.string(),
210
- property: Joi.string(),
211
- content: Joi.string(),
212
- itemprop: Joi.string(),
213
- }).unknown();
214
- const FooterLinkItemSchema = Joi.object({
215
- to: Joi.string(),
216
- href: URISchema,
217
- html: Joi.string(),
218
- label: Joi.string(),
219
- })
220
- .xor('to', 'href', 'html')
221
- .with('to', 'label')
222
- .with('href', 'label')
223
- .nand('html', 'label') // We allow any unknown attributes on the links
224
- // (users may need additional attributes like target, aria-role, data-customAttribute...)
225
- .unknown();
226
- const CustomCssSchema = Joi.alternatives()
227
- .try(Joi.array().items(Joi.string().required()), Joi.string().required())
228
- .optional();
229
- const ThemeConfigSchema = Joi.object({
230
- // TODO temporary (@alpha-58)
231
- disableDarkMode: Joi.any().forbidden().messages({
232
- 'any.unknown':
233
- 'disableDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.disableSwitch = true',
234
- }),
235
- // TODO temporary (@alpha-58)
236
- defaultDarkMode: Joi.any().forbidden().messages({
237
- 'any.unknown':
238
- 'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
239
- }),
240
- customCss: CustomCssSchema,
241
- colorMode: ColorModeSchema,
242
- image: Joi.string(),
243
- docs: DocsSchema,
244
- metadata: Joi.array()
245
- .items(HtmlMetadataSchema)
246
- .default(DEFAULT_CONFIG.metadata),
247
- metadatas: Joi.any().forbidden().messages({
248
- 'any.unknown':
249
- 'themeConfig.metadatas has been renamed as themeConfig.metadata. See https://github.com/facebook/docusaurus/pull/5871',
250
- }),
251
- announcementBar: Joi.object({
252
- id: Joi.string().default('announcement-bar'),
253
- content: Joi.string().required(),
254
- backgroundColor: Joi.string(),
255
- textColor: Joi.string(),
256
- isCloseable: Joi.bool().default(true),
257
- }).optional(),
258
- navbar: Joi.object({
259
- style: Joi.string().equal('dark', 'primary'),
260
- hideOnScroll: Joi.bool().default(DEFAULT_CONFIG.navbar.hideOnScroll),
261
- // TODO temporary (@alpha-58)
262
- links: Joi.any().forbidden().messages({
263
- 'any.unknown':
264
- 'themeConfig.navbar.links has been renamed as themeConfig.navbar.items',
265
- }),
266
- items: Joi.array()
267
- .items(NavbarItemSchema)
268
- .default(DEFAULT_CONFIG.navbar.items),
269
- title: Joi.string().allow('', null),
270
- logo: Joi.object({
271
- alt: Joi.string().allow(''),
272
- src: Joi.string().required(),
273
- srcDark: Joi.string(),
274
- width: Joi.alternatives().try(Joi.string(), Joi.number()),
275
- height: Joi.alternatives().try(Joi.string(), Joi.number()),
276
- href: Joi.string(),
277
- target: Joi.string(),
278
- }),
279
- }).default(DEFAULT_CONFIG.navbar),
280
- footer: Joi.object({
281
- style: Joi.string().equal('dark', 'light').default('light'),
282
- logo: Joi.object({
283
- alt: Joi.string().allow(''),
284
- src: Joi.string(),
285
- srcDark: Joi.string(),
286
- // TODO infer this from reading the image
287
- width: Joi.alternatives().try(Joi.string(), Joi.number()),
288
- height: Joi.alternatives().try(Joi.string(), Joi.number()),
289
- href: Joi.string(),
290
- }),
291
- copyright: Joi.string(),
292
- links: Joi.array()
293
- .items(
294
- Joi.object({
295
- title: Joi.string().allow(null),
296
- items: Joi.array().items(FooterLinkItemSchema).default([]),
297
- }),
298
- )
299
- .default([]),
300
- }).optional(),
301
- prism: Joi.object({
302
- theme: Joi.object({
303
- plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
304
- styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
305
- }),
306
- darkTheme: Joi.object({
307
- plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
308
- styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
309
- }),
310
- defaultLanguage: Joi.string(),
311
- additionalLanguages: Joi.array()
312
- .items(Joi.string())
313
- .default(DEFAULT_CONFIG.prism.additionalLanguages),
314
- })
315
- .default(DEFAULT_CONFIG.prism)
316
- .unknown(),
317
- hideableSidebar: Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
318
- sidebarCollapsible: Joi.forbidden().messages({
319
- 'any.unknown':
320
- 'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs',
321
- }),
322
- tableOfContents: Joi.object({
323
- minHeadingLevel: Joi.number()
324
- .default(DEFAULT_CONFIG.tableOfContents.minHeadingLevel)
325
- .when('maxHeadingLevel', {
326
- is: Joi.exist(),
327
- then: Joi.number()
328
- .integer()
329
- .min(2)
330
- .max(6)
331
- .max(Joi.ref('maxHeadingLevel')),
332
- otherwise: Joi.number().integer().min(2).max(6),
333
- }),
334
- maxHeadingLevel: Joi.number()
335
- .integer()
336
- .min(2)
337
- .max(6)
338
- .default(DEFAULT_CONFIG.tableOfContents.maxHeadingLevel),
339
- }).default(DEFAULT_CONFIG.tableOfContents),
340
- });
341
- export {DEFAULT_CONFIG, ThemeConfigSchema};
342
- export function validateThemeConfig({validate, themeConfig}) {
343
- return validate(ThemeConfigSchema, themeConfig);
344
- }
@@ -1,116 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`getTranslationFiles should return translation files matching snapshot 1`] = `
4
- Array [
5
- Object {
6
- "content": Object {
7
- "item.label.Dropdown": Object {
8
- "description": "Navbar item with label Dropdown",
9
- "message": "Dropdown",
10
- },
11
- "item.label.Dropdown item 1": Object {
12
- "description": "Navbar item with label Dropdown item 1",
13
- "message": "Dropdown item 1",
14
- },
15
- "item.label.Dropdown item 2": Object {
16
- "description": "Navbar item with label Dropdown item 2",
17
- "message": "Dropdown item 2",
18
- },
19
- "title": Object {
20
- "description": "The title in the navbar",
21
- "message": "navbar title",
22
- },
23
- },
24
- "path": "navbar",
25
- },
26
- Object {
27
- "content": Object {
28
- "copyright": Object {
29
- "description": "The footer copyright",
30
- "message": "Copyright FB",
31
- },
32
- "link.item.label.Link 1": Object {
33
- "description": "The label of footer link with label=Link 1 linking to https://facebook.com",
34
- "message": "Link 1",
35
- },
36
- "link.item.label.Link 2": Object {
37
- "description": "The label of footer link with label=Link 2 linking to https://facebook.com",
38
- "message": "Link 2",
39
- },
40
- "link.item.label.Link 3": Object {
41
- "description": "The label of footer link with label=Link 3 linking to https://facebook.com",
42
- "message": "Link 3",
43
- },
44
- "link.title.Footer link column 1": Object {
45
- "description": "The title of the footer links column with title=Footer link column 1 in the footer",
46
- "message": "Footer link column 1",
47
- },
48
- "link.title.Footer link column 2": Object {
49
- "description": "The title of the footer links column with title=Footer link column 2 in the footer",
50
- "message": "Footer link column 2",
51
- },
52
- },
53
- "path": "footer",
54
- },
55
- ]
56
- `;
57
-
58
- exports[`translateThemeConfig should return translated themeConfig matching snapshot 1`] = `
59
- Object {
60
- "announcementBar": Object {},
61
- "colorMode": Object {},
62
- "docs": Object {
63
- "versionPersistence": "none",
64
- },
65
- "footer": Object {
66
- "copyright": "Copyright FB (translated)",
67
- "links": Array [
68
- Object {
69
- "items": Array [
70
- Object {
71
- "label": "Link 1 (translated)",
72
- "to": "https://facebook.com",
73
- },
74
- Object {
75
- "label": "Link 2 (translated)",
76
- "to": "https://facebook.com",
77
- },
78
- ],
79
- "title": "Footer link column 1 (translated)",
80
- },
81
- Object {
82
- "items": Array [
83
- Object {
84
- "label": "Link 3 (translated)",
85
- "to": "https://facebook.com",
86
- },
87
- ],
88
- "title": "Footer link column 2 (translated)",
89
- },
90
- ],
91
- "style": "light",
92
- },
93
- "hideableSidebar": true,
94
- "navbar": Object {
95
- "hideOnScroll": false,
96
- "items": Array [
97
- Object {
98
- "items": Array [
99
- Object {
100
- "items": Array [],
101
- "label": "Dropdown item 1 (translated)",
102
- },
103
- Object {
104
- "items": Array [],
105
- "label": "Dropdown item 2 (translated)",
106
- },
107
- ],
108
- "label": "Dropdown (translated)",
109
- },
110
- ],
111
- "style": "dark",
112
- "title": "navbar title (translated)",
113
- },
114
- "prism": Object {},
115
- }
116
- `;