@docusaurus/theme-classic 2.0.0-beta.15 → 2.0.0-beta.16
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.
- package/lib/getSwizzleConfig.js +102 -0
- package/lib/index.js +14 -11
- package/lib/theme-classic.d.ts +123 -97
- package/lib/translations.js +29 -32
- package/lib/validateThemeConfig.js +7 -4
- package/lib-next/theme/AnnouncementBar/index.js +1 -4
- package/lib-next/theme/BackToTopButton/index.js +6 -6
- package/lib-next/theme/BackToTopButton/styles.module.css +3 -1
- package/lib-next/theme/BlogLayout/index.js +1 -4
- package/lib-next/theme/BlogListPage/index.js +1 -4
- package/lib-next/theme/BlogListPaginator/index.js +1 -4
- package/lib-next/theme/BlogPostAuthor/index.js +18 -24
- package/lib-next/theme/BlogPostItem/index.js +12 -4
- package/lib-next/theme/BlogPostPage/index.js +4 -6
- package/lib-next/theme/BlogPostPaginator/index.js +1 -4
- package/lib-next/theme/BlogTagsListPage/index.js +1 -4
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -2
- package/lib-next/theme/CodeBlock/index.js +2 -1
- package/lib-next/theme/Details/index.js +2 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +76 -0
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/lib-next/theme/DocCard/index.js +12 -1
- package/lib-next/theme/DocCard/styles.module.css +1 -1
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +2 -0
- package/lib-next/theme/DocItem/index.js +8 -5
- package/lib-next/theme/DocPage/index.js +2 -4
- package/lib-next/theme/DocPage/styles.module.css +3 -3
- package/lib-next/theme/DocPaginator/index.js +1 -4
- package/lib-next/theme/DocSidebar/styles.module.css +4 -4
- package/lib-next/theme/DocSidebarItem/index.js +39 -14
- package/lib-next/theme/DocSidebarItem/styles.module.css +3 -10
- package/lib-next/theme/DocTagsListPage/index.js +1 -4
- package/lib-next/theme/DocVersionBadge/index.js +8 -1
- package/lib-next/theme/Footer/index.js +8 -4
- package/lib-next/theme/Heading/index.js +0 -1
- package/lib-next/theme/Heading/styles.module.css +16 -0
- package/lib-next/theme/IconArrow/index.js +1 -4
- package/lib-next/theme/IconEdit/index.js +1 -4
- package/lib-next/theme/IconExternalLink/index.js +1 -4
- package/lib-next/theme/IconLanguage/index.js +1 -4
- package/lib-next/theme/IconMenu/index.js +6 -4
- package/lib-next/theme/Layout/index.js +1 -4
- package/lib-next/theme/LayoutHead/index.js +4 -0
- package/lib-next/theme/Logo/index.js +1 -4
- package/lib-next/theme/MDXComponents/index.js +4 -3
- package/lib-next/theme/MDXPage/index.js +1 -4
- package/lib-next/theme/Navbar/index.js +1 -3
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +1 -3
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -2
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +1 -3
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +8 -1
- package/lib-next/theme/NavbarItem/index.js +2 -2
- package/lib-next/theme/NotFound.js +1 -4
- package/lib-next/theme/PaginatorNavLink/index.js +1 -4
- package/lib-next/theme/SearchBar.js +1 -1
- package/lib-next/theme/SearchMetadata/index.js +11 -6
- package/lib-next/theme/SkipToContent/index.js +1 -3
- package/lib-next/theme/TOC/index.js +2 -5
- package/lib-next/theme/TOCInline/index.js +1 -4
- package/lib-next/theme/TOCItems/index.js +3 -3
- package/lib-next/theme/TabItem/index.js +1 -4
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -1
- package/lib-next/theme/Tabs/index.js +1 -1
- package/lib-next/theme/Tag/index.js +1 -4
- package/lib-next/theme/TagsListByLetter/index.js +1 -3
- package/lib-next/theme/ThemedImage/index.js +1 -4
- package/lib-next/theme/ThemedImage/styles.module.css +2 -2
- package/lib-next/theme/Toggle/index.js +25 -2
- package/lib-next/theme/prism-include-languages.js +17 -23
- package/package.json +21 -22
- package/src/getSwizzleConfig.ts +101 -0
- package/src/index.ts +7 -21
- package/src/theme/AnnouncementBar/index.tsx +1 -3
- package/src/theme/BackToTopButton/index.tsx +8 -7
- package/src/theme/BackToTopButton/styles.module.css +3 -1
- package/src/theme/BlogLayout/index.tsx +1 -3
- package/src/theme/BlogListPage/index.tsx +1 -3
- package/src/theme/BlogListPaginator/index.tsx +1 -3
- package/src/theme/BlogPostAuthor/index.tsx +18 -23
- package/src/theme/BlogPostItem/index.tsx +10 -4
- package/src/theme/BlogPostPage/index.tsx +4 -5
- package/src/theme/BlogPostPaginator/index.tsx +1 -3
- package/src/theme/BlogTagsListPage/index.tsx +1 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +3 -1
- package/src/theme/CodeBlock/index.tsx +2 -1
- package/src/theme/Details/index.tsx +2 -1
- package/src/theme/DocBreadcrumbs/index.tsx +91 -0
- package/src/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/src/theme/DocCard/index.tsx +10 -1
- package/src/theme/DocCard/styles.module.css +1 -1
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +2 -0
- package/src/theme/DocItem/index.tsx +7 -4
- package/src/theme/DocPage/index.tsx +2 -4
- package/src/theme/DocPage/styles.module.css +3 -3
- package/src/theme/DocPaginator/index.tsx +1 -3
- package/src/theme/DocSidebar/styles.module.css +4 -4
- package/src/theme/DocSidebarItem/index.tsx +43 -13
- package/src/theme/DocSidebarItem/styles.module.css +3 -10
- package/src/theme/DocTagsListPage/index.tsx +1 -3
- package/src/theme/DocVersionBadge/index.tsx +6 -1
- package/src/theme/Footer/index.tsx +8 -4
- package/src/theme/Heading/index.tsx +0 -1
- package/src/theme/Heading/styles.module.css +16 -0
- package/src/theme/IconArrow/index.tsx +1 -3
- package/src/theme/IconEdit/index.tsx +4 -3
- package/src/theme/IconExternalLink/index.tsx +4 -3
- package/src/theme/IconLanguage/index.tsx +5 -3
- package/src/theme/IconMenu/index.tsx +1 -3
- package/src/theme/Layout/index.tsx +1 -3
- package/src/theme/LayoutHead/index.tsx +4 -0
- package/src/theme/Logo/index.tsx +1 -3
- package/src/theme/MDXComponents/index.tsx +4 -3
- package/src/theme/MDXPage/index.tsx +1 -3
- package/src/theme/Navbar/index.tsx +1 -3
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +1 -3
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -2
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -3
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +8 -1
- package/src/theme/NavbarItem/index.tsx +2 -2
- package/src/theme/NotFound.tsx +1 -3
- package/src/theme/PaginatorNavLink/index.tsx +1 -3
- package/src/theme/SearchBar.tsx +2 -1
- package/src/theme/SearchMetadata/index.tsx +12 -6
- package/src/theme/SkipToContent/index.tsx +1 -3
- package/src/theme/TOC/index.tsx +3 -5
- package/src/theme/TOCCollapsible/index.tsx +2 -2
- package/src/theme/TOCInline/index.tsx +3 -5
- package/src/theme/TOCItems/index.tsx +11 -7
- package/src/theme/TabItem/index.tsx +5 -3
- package/src/theme/Tabs/index.tsx +1 -1
- package/src/theme/Tag/index.tsx +1 -3
- package/src/theme/TagsListByLetter/index.tsx +1 -3
- package/src/theme/ThemedImage/index.tsx +1 -3
- package/src/theme/ThemedImage/styles.module.css +2 -2
- package/src/theme/Toggle/index.tsx +26 -2
- package/src/theme/prism-include-languages.ts +20 -23
- package/src/theme-classic.d.ts +123 -97
- package/src/translations.ts +41 -39
- package/src/validateThemeConfig.ts +10 -8
- package/lib-next/theme/DocSidebarItems/styles.module.css +0 -20
- package/lib-next/theme/Heading/styles.css +0 -22
- package/src/theme/DocSidebarItems/styles.module.css +0 -20
- package/src/theme/Heading/styles.css +0 -22
package/src/translations.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
SimpleFooter,
|
|
16
16
|
} from '@docusaurus/theme-common';
|
|
17
17
|
|
|
18
|
-
import
|
|
18
|
+
import _ from 'lodash';
|
|
19
19
|
import {mergeTranslations} from '@docusaurus/utils';
|
|
20
20
|
|
|
21
21
|
function getNavbarTranslationFile(navbar: Navbar): TranslationFileContent {
|
|
@@ -30,15 +30,17 @@ function getNavbarTranslationFile(navbar: Navbar): TranslationFileContent {
|
|
|
30
30
|
|
|
31
31
|
const allNavbarItems = flattenNavbarItems(navbar.items);
|
|
32
32
|
|
|
33
|
-
const navbarItemsTranslations: TranslationFileContent =
|
|
34
|
-
allNavbarItems
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const navbarItemsTranslations: TranslationFileContent = Object.fromEntries(
|
|
34
|
+
allNavbarItems
|
|
35
|
+
.filter((navbarItem) => navbarItem.label)
|
|
36
|
+
.map((navbarItem) => [
|
|
37
|
+
`item.label.${navbarItem.label}`,
|
|
38
|
+
{
|
|
39
|
+
message: navbarItem.label!,
|
|
40
|
+
description: `Navbar item with label ${navbarItem.label}`,
|
|
41
|
+
},
|
|
42
|
+
]),
|
|
43
|
+
);
|
|
42
44
|
|
|
43
45
|
const titleTranslations: TranslationFileContent = navbar.title
|
|
44
46
|
? {title: {message: navbar.title, description: 'The title in the navbar'}}
|
|
@@ -78,33 +80,33 @@ function isMultiColumnFooterLinks(
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
function getFooterTranslationFile(footer: Footer): TranslationFileContent {
|
|
81
|
-
const footerLinkTitles: TranslationFileContent =
|
|
82
|
-
isMultiColumnFooterLinks(footer.links)
|
|
83
|
-
? footer.links.filter((link) =>
|
|
84
|
-
: []
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
const footerLinkTitles: TranslationFileContent = Object.fromEntries(
|
|
84
|
+
(isMultiColumnFooterLinks(footer.links)
|
|
85
|
+
? footer.links.filter((link) => link.title)
|
|
86
|
+
: []
|
|
87
|
+
).map((link) => [
|
|
88
|
+
`link.title.${link.title}`,
|
|
89
|
+
{
|
|
90
|
+
message: link.title!,
|
|
91
|
+
description: `The title of the footer links column with title=${link.title} in the footer`,
|
|
92
|
+
},
|
|
93
|
+
]),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const footerLinkLabels: TranslationFileContent = Object.fromEntries(
|
|
97
|
+
(isMultiColumnFooterLinks(footer.links)
|
|
98
|
+
? footer.links.flatMap((link) => link.items).filter((link) => link.label)
|
|
99
|
+
: footer.links.filter((link) => link.label)
|
|
100
|
+
).map((link) => [
|
|
101
|
+
`link.item.label.${link.label}`,
|
|
102
|
+
{
|
|
103
|
+
message: link.label!,
|
|
104
|
+
description: `The label of footer link with label=${
|
|
105
|
+
link.label
|
|
106
|
+
} linking to ${link.to ?? link.href}`,
|
|
107
|
+
},
|
|
108
|
+
]),
|
|
109
|
+
);
|
|
108
110
|
|
|
109
111
|
const copyright: TranslationFileContent = footer.copyright
|
|
110
112
|
? {
|
|
@@ -171,12 +173,12 @@ export function translateThemeConfig({
|
|
|
171
173
|
themeConfig,
|
|
172
174
|
translationFiles,
|
|
173
175
|
}: {
|
|
174
|
-
//
|
|
176
|
+
// To make TS correctly figure out the contravariance in parameter.
|
|
175
177
|
// In practice it's always normalized
|
|
176
178
|
themeConfig: ThemeConfig;
|
|
177
179
|
translationFiles: TranslationFile[];
|
|
178
180
|
}): ThemeConfig {
|
|
179
|
-
const translationFilesMap: Record<string, TranslationFile> = keyBy(
|
|
181
|
+
const translationFilesMap: Record<string, TranslationFile> = _.keyBy(
|
|
180
182
|
translationFiles,
|
|
181
183
|
(f) => f.path,
|
|
182
184
|
);
|
|
@@ -29,7 +29,7 @@ const DEFAULT_COLOR_MODE_CONFIG = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const DEFAULT_CONFIG = {
|
|
32
|
+
export const DEFAULT_CONFIG = {
|
|
33
33
|
colorMode: DEFAULT_COLOR_MODE_CONFIG,
|
|
34
34
|
docs: DEFAULT_DOCS_CONFIG,
|
|
35
35
|
metadata: [],
|
|
@@ -54,8 +54,8 @@ const NavbarItemBaseSchema = Joi.object({
|
|
|
54
54
|
label: Joi.string(),
|
|
55
55
|
className: Joi.string(),
|
|
56
56
|
})
|
|
57
|
-
// We allow any unknown attributes on the links
|
|
58
|
-
//
|
|
57
|
+
// We allow any unknown attributes on the links (users may need additional
|
|
58
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
59
59
|
.unknown();
|
|
60
60
|
|
|
61
61
|
const DefaultNavbarItemSchema = NavbarItemBaseSchema.append({
|
|
@@ -116,6 +116,10 @@ const DropdownSubitemSchema = Joi.object({
|
|
|
116
116
|
is: itemWithType('doc'),
|
|
117
117
|
then: DocItemSchema,
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
is: itemWithType('docSidebar'),
|
|
121
|
+
then: DocSidebarItemSchema,
|
|
122
|
+
},
|
|
119
123
|
{
|
|
120
124
|
is: itemWithType(undefined),
|
|
121
125
|
then: DefaultNavbarItemSchema,
|
|
@@ -251,15 +255,15 @@ const FooterLinkItemSchema = Joi.object({
|
|
|
251
255
|
.with('to', 'label')
|
|
252
256
|
.with('href', 'label')
|
|
253
257
|
.nand('html', 'label')
|
|
254
|
-
// We allow any unknown attributes on the links
|
|
255
|
-
//
|
|
258
|
+
// We allow any unknown attributes on the links (users may need additional
|
|
259
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
256
260
|
.unknown();
|
|
257
261
|
|
|
258
262
|
const CustomCssSchema = Joi.alternatives()
|
|
259
263
|
.try(Joi.array().items(Joi.string().required()), Joi.string().required())
|
|
260
264
|
.optional();
|
|
261
265
|
|
|
262
|
-
const ThemeConfigSchema = Joi.object({
|
|
266
|
+
export const ThemeConfigSchema = Joi.object({
|
|
263
267
|
// TODO temporary (@alpha-58)
|
|
264
268
|
disableDarkMode: Joi.any().forbidden().messages({
|
|
265
269
|
'any.unknown':
|
|
@@ -382,8 +386,6 @@ const ThemeConfigSchema = Joi.object({
|
|
|
382
386
|
}).default(DEFAULT_CONFIG.tableOfContents),
|
|
383
387
|
});
|
|
384
388
|
|
|
385
|
-
export {DEFAULT_CONFIG, ThemeConfigSchema};
|
|
386
|
-
|
|
387
389
|
export function validateThemeConfig({
|
|
388
390
|
validate,
|
|
389
391
|
themeConfig,
|
|
@@ -1,20 +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
|
-
@media (min-width: 997px) {
|
|
9
|
-
.menuLinkText {
|
|
10
|
-
cursor: initial;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.menuLinkText:hover {
|
|
14
|
-
background: none;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.menuLinkText.hasHref {
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,22 +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
|
-
.hash-link {
|
|
9
|
-
opacity: 0;
|
|
10
|
-
padding-left: 0.5rem;
|
|
11
|
-
transition: opacity var(--ifm-transition-fast);
|
|
12
|
-
user-select: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.hash-link::before {
|
|
16
|
-
content: '#';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.hash-link:focus,
|
|
20
|
-
*:hover > .hash-link {
|
|
21
|
-
opacity: 1;
|
|
22
|
-
}
|
|
@@ -1,20 +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
|
-
@media (min-width: 997px) {
|
|
9
|
-
.menuLinkText {
|
|
10
|
-
cursor: initial;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.menuLinkText:hover {
|
|
14
|
-
background: none;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.menuLinkText.hasHref {
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,22 +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
|
-
.hash-link {
|
|
9
|
-
opacity: 0;
|
|
10
|
-
padding-left: 0.5rem;
|
|
11
|
-
transition: opacity var(--ifm-transition-fast);
|
|
12
|
-
user-select: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.hash-link::before {
|
|
16
|
-
content: '#';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.hash-link:focus,
|
|
20
|
-
*:hover > .hash-link {
|
|
21
|
-
opacity: 1;
|
|
22
|
-
}
|