@docusaurus/theme-classic 0.0.0-4870 → 0.0.0-4871
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/theme-classic.d.ts +13 -1
- package/lib/validateThemeConfig.js +12 -0
- package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
- package/lib-next/theme/NavbarItem/index.js +2 -0
- package/package.json +13 -13
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/index.tsx +2 -0
- package/src/theme-classic.d.ts +13 -1
- package/src/validateThemeConfig.ts +14 -0
package/lib/theme-classic.d.ts
CHANGED
|
@@ -872,6 +872,16 @@ declare module '@theme/NavbarItem/DocSidebarNavbarItem' {
|
|
|
872
872
|
export default function DocSidebarNavbarItem(props: Props): JSX.Element;
|
|
873
873
|
}
|
|
874
874
|
|
|
875
|
+
declare module '@theme/NavbarItem/HtmlNavbarItem' {
|
|
876
|
+
import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
|
|
877
|
+
|
|
878
|
+
export interface Props extends DefaultNavbarItemProps {
|
|
879
|
+
readonly value: string;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export default function HtmlNavbarItem(props: Props): JSX.Element;
|
|
883
|
+
}
|
|
884
|
+
|
|
875
885
|
declare module '@theme/NavbarItem' {
|
|
876
886
|
import type {ComponentProps} from 'react';
|
|
877
887
|
import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
|
|
@@ -882,12 +892,14 @@ declare module '@theme/NavbarItem' {
|
|
|
882
892
|
import type {Props as DocsVersionDropdownNavbarItemProps} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
883
893
|
import type {Props as LocaleDropdownNavbarItemProps} from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
884
894
|
import type {Props as SearchNavbarItemProps} from '@theme/NavbarItem/SearchNavbarItem';
|
|
895
|
+
import type {Props as HtmlNavbarItemProps} from '@theme/NavbarItem/HtmlNavbarItem';
|
|
885
896
|
|
|
886
897
|
export type LinkLikeNavbarItemProps =
|
|
887
898
|
| ({readonly type?: 'default'} & DefaultNavbarItemProps)
|
|
888
899
|
| ({readonly type: 'doc'} & DocNavbarItemProps)
|
|
889
900
|
| ({readonly type: 'docsVersion'} & DocsVersionNavbarItemProps)
|
|
890
|
-
| ({readonly type: 'docSidebar'} & DocSidebarNavbarItemProps)
|
|
901
|
+
| ({readonly type: 'docSidebar'} & DocSidebarNavbarItemProps)
|
|
902
|
+
| ({readonly type: 'html'} & HtmlNavbarItemProps);
|
|
891
903
|
|
|
892
904
|
export type Props = ComponentProps<'a'> & {
|
|
893
905
|
readonly position?: 'left' | 'right';
|
|
@@ -91,6 +91,12 @@ const DocSidebarItemSchema = NavbarItemBaseSchema.append({
|
|
|
91
91
|
docsPluginId: _utilsValidation.Joi.string()
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
const HtmlNavbarItemSchema = _utilsValidation.Joi.object({
|
|
95
|
+
className: _utilsValidation.Joi.string(),
|
|
96
|
+
type: _utilsValidation.Joi.string().equal('html').required(),
|
|
97
|
+
value: _utilsValidation.Joi.string().required()
|
|
98
|
+
});
|
|
99
|
+
|
|
94
100
|
const itemWithType = type => {
|
|
95
101
|
// because equal(undefined) is not supported :/
|
|
96
102
|
const typeSchema = type ? _utilsValidation.Joi.string().required().equal(type) : _utilsValidation.Joi.string().forbidden();
|
|
@@ -114,6 +120,9 @@ const DropdownSubitemSchema = _utilsValidation.Joi.object({
|
|
|
114
120
|
}, {
|
|
115
121
|
is: itemWithType(undefined),
|
|
116
122
|
then: DefaultNavbarItemSchema
|
|
123
|
+
}, {
|
|
124
|
+
is: itemWithType('html'),
|
|
125
|
+
then: HtmlNavbarItemSchema
|
|
117
126
|
}, {
|
|
118
127
|
is: _utilsValidation.Joi.alternatives().try(itemWithType('dropdown'), itemWithType('docsVersionDropdown'), itemWithType('localeDropdown'), itemWithType('search')),
|
|
119
128
|
then: _utilsValidation.Joi.forbidden().messages({
|
|
@@ -169,6 +178,9 @@ const NavbarItemSchema = _utilsValidation.Joi.object({
|
|
|
169
178
|
}, {
|
|
170
179
|
is: itemWithType('search'),
|
|
171
180
|
then: SearchItemSchema
|
|
181
|
+
}, {
|
|
182
|
+
is: itemWithType('html'),
|
|
183
|
+
then: HtmlNavbarItemSchema
|
|
172
184
|
}, {
|
|
173
185
|
is: itemWithType(undefined),
|
|
174
186
|
then: _utilsValidation.Joi.object().when('.', {
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
export default function HtmlNavbarItem({
|
|
10
|
+
value,
|
|
11
|
+
className,
|
|
12
|
+
mobile = false,
|
|
13
|
+
isDropdownItem = false,
|
|
14
|
+
}) {
|
|
15
|
+
const Comp = isDropdownItem ? 'li' : 'div';
|
|
16
|
+
return (
|
|
17
|
+
<Comp
|
|
18
|
+
className={clsx(
|
|
19
|
+
{
|
|
20
|
+
navbar__item: !mobile && !isDropdownItem,
|
|
21
|
+
'menu__list-item': mobile,
|
|
22
|
+
},
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
dangerouslySetInnerHTML={{
|
|
26
|
+
__html: value,
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -9,11 +9,13 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
|
9
9
|
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
10
10
|
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
11
11
|
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|
12
|
+
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
|
|
12
13
|
const NavbarItemComponents = {
|
|
13
14
|
default: () => DefaultNavbarItem,
|
|
14
15
|
localeDropdown: () => LocaleDropdownNavbarItem,
|
|
15
16
|
search: () => SearchNavbarItem,
|
|
16
17
|
dropdown: () => DropdownNavbarItem,
|
|
18
|
+
html: () => HtmlNavbarItem,
|
|
17
19
|
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
18
20
|
// loaded. See https://github.com/facebook/docusaurus/issues/3360
|
|
19
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4871",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4871",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4871",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4871",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4871",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4871",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4871",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4871",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4871",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4871",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@babel/cli": "^7.17.6",
|
|
46
46
|
"@babel/core": "^7.17.9",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.7",
|
|
48
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
49
|
-
"@docusaurus/types": "0.0.0-
|
|
48
|
+
"@docusaurus/module-type-aliases": "0.0.0-4871",
|
|
49
|
+
"@docusaurus/types": "0.0.0-4871",
|
|
50
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
51
51
|
"@types/prismjs": "^1.26.0",
|
|
52
52
|
"@types/rtlcss": "^3.1.3",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "d8f14db917aa6048c52018f69da5486e5813b02e"
|
|
66
66
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
|
|
11
|
+
import type {Props} from '@theme/NavbarItem/HtmlNavbarItem';
|
|
12
|
+
|
|
13
|
+
export default function HtmlNavbarItem({
|
|
14
|
+
value,
|
|
15
|
+
className,
|
|
16
|
+
mobile = false,
|
|
17
|
+
isDropdownItem = false,
|
|
18
|
+
}: Props): JSX.Element {
|
|
19
|
+
const Comp = isDropdownItem ? 'li' : 'div';
|
|
20
|
+
return (
|
|
21
|
+
<Comp
|
|
22
|
+
className={clsx(
|
|
23
|
+
{
|
|
24
|
+
navbar__item: !mobile && !isDropdownItem,
|
|
25
|
+
'menu__list-item': mobile,
|
|
26
|
+
},
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
dangerouslySetInnerHTML={{__html: value}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -12,6 +12,7 @@ import DropdownNavbarItem, {
|
|
|
12
12
|
} from '@theme/NavbarItem/DropdownNavbarItem';
|
|
13
13
|
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
14
14
|
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|
15
|
+
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
|
|
15
16
|
import type {Types, Props} from '@theme/NavbarItem';
|
|
16
17
|
|
|
17
18
|
const NavbarItemComponents: {
|
|
@@ -23,6 +24,7 @@ const NavbarItemComponents: {
|
|
|
23
24
|
localeDropdown: () => LocaleDropdownNavbarItem,
|
|
24
25
|
search: () => SearchNavbarItem,
|
|
25
26
|
dropdown: () => DropdownNavbarItem,
|
|
27
|
+
html: () => HtmlNavbarItem,
|
|
26
28
|
|
|
27
29
|
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
28
30
|
// loaded. See https://github.com/facebook/docusaurus/issues/3360
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -872,6 +872,16 @@ declare module '@theme/NavbarItem/DocSidebarNavbarItem' {
|
|
|
872
872
|
export default function DocSidebarNavbarItem(props: Props): JSX.Element;
|
|
873
873
|
}
|
|
874
874
|
|
|
875
|
+
declare module '@theme/NavbarItem/HtmlNavbarItem' {
|
|
876
|
+
import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
|
|
877
|
+
|
|
878
|
+
export interface Props extends DefaultNavbarItemProps {
|
|
879
|
+
readonly value: string;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export default function HtmlNavbarItem(props: Props): JSX.Element;
|
|
883
|
+
}
|
|
884
|
+
|
|
875
885
|
declare module '@theme/NavbarItem' {
|
|
876
886
|
import type {ComponentProps} from 'react';
|
|
877
887
|
import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
|
|
@@ -882,12 +892,14 @@ declare module '@theme/NavbarItem' {
|
|
|
882
892
|
import type {Props as DocsVersionDropdownNavbarItemProps} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
883
893
|
import type {Props as LocaleDropdownNavbarItemProps} from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
884
894
|
import type {Props as SearchNavbarItemProps} from '@theme/NavbarItem/SearchNavbarItem';
|
|
895
|
+
import type {Props as HtmlNavbarItemProps} from '@theme/NavbarItem/HtmlNavbarItem';
|
|
885
896
|
|
|
886
897
|
export type LinkLikeNavbarItemProps =
|
|
887
898
|
| ({readonly type?: 'default'} & DefaultNavbarItemProps)
|
|
888
899
|
| ({readonly type: 'doc'} & DocNavbarItemProps)
|
|
889
900
|
| ({readonly type: 'docsVersion'} & DocsVersionNavbarItemProps)
|
|
890
|
-
| ({readonly type: 'docSidebar'} & DocSidebarNavbarItemProps)
|
|
901
|
+
| ({readonly type: 'docSidebar'} & DocSidebarNavbarItemProps)
|
|
902
|
+
| ({readonly type: 'html'} & HtmlNavbarItemProps);
|
|
891
903
|
|
|
892
904
|
export type Props = ComponentProps<'a'> & {
|
|
893
905
|
readonly position?: 'left' | 'right';
|
|
@@ -93,6 +93,12 @@ const DocSidebarItemSchema = NavbarItemBaseSchema.append({
|
|
|
93
93
|
docsPluginId: Joi.string(),
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
const HtmlNavbarItemSchema = Joi.object({
|
|
97
|
+
className: Joi.string(),
|
|
98
|
+
type: Joi.string().equal('html').required(),
|
|
99
|
+
value: Joi.string().required(),
|
|
100
|
+
});
|
|
101
|
+
|
|
96
102
|
const itemWithType = (type: string | undefined) => {
|
|
97
103
|
// because equal(undefined) is not supported :/
|
|
98
104
|
const typeSchema = type
|
|
@@ -125,6 +131,10 @@ const DropdownSubitemSchema = Joi.object({
|
|
|
125
131
|
is: itemWithType(undefined),
|
|
126
132
|
then: DefaultNavbarItemSchema,
|
|
127
133
|
},
|
|
134
|
+
{
|
|
135
|
+
is: itemWithType('html'),
|
|
136
|
+
then: HtmlNavbarItemSchema,
|
|
137
|
+
},
|
|
128
138
|
{
|
|
129
139
|
is: Joi.alternatives().try(
|
|
130
140
|
itemWithType('dropdown'),
|
|
@@ -196,6 +206,10 @@ const NavbarItemSchema = Joi.object({
|
|
|
196
206
|
is: itemWithType('search'),
|
|
197
207
|
then: SearchItemSchema,
|
|
198
208
|
},
|
|
209
|
+
{
|
|
210
|
+
is: itemWithType('html'),
|
|
211
|
+
then: HtmlNavbarItemSchema,
|
|
212
|
+
},
|
|
199
213
|
{
|
|
200
214
|
is: itemWithType(undefined),
|
|
201
215
|
then: Joi.object().when('.', {
|