@docusaurus/plugin-content-docs 0.0.0-4548 → 0.0.0-4549
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.
|
@@ -33,12 +33,14 @@ function normalizeItem(item) {
|
|
|
33
33
|
return normalizeCategoriesShorthand(item).flatMap((subItem) => normalizeItem(subItem));
|
|
34
34
|
}
|
|
35
35
|
if (item.type === 'category') {
|
|
36
|
-
if (typeof item.items !== 'undefined' &&
|
|
37
|
-
throw new Error(`Invalid category ${JSON.stringify(item)}: items must be an array`);
|
|
36
|
+
if (typeof item.items !== 'undefined' && typeof item.items !== 'object') {
|
|
37
|
+
throw new Error(`Invalid category ${JSON.stringify(item)}: items must be an array of sidebar items or a category shorthand`);
|
|
38
38
|
}
|
|
39
39
|
const normalizedCategory = {
|
|
40
40
|
...item,
|
|
41
|
-
items: item.items
|
|
41
|
+
items: Array.isArray(item.items)
|
|
42
|
+
? item.items.flatMap((subItem) => normalizeItem(subItem))
|
|
43
|
+
: normalizeCategoriesShorthand(item.items).flatMap((subItem) => normalizeItem(subItem)),
|
|
42
44
|
};
|
|
43
45
|
return [normalizedCategory];
|
|
44
46
|
}
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -64,11 +64,11 @@ export declare type SidebarItemCategoryLinkGeneratedIndex = {
|
|
|
64
64
|
export declare type SidebarItemCategoryLinkConfig = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndexConfig;
|
|
65
65
|
export declare type SidebarItemCategoryLink = SidebarItemCategoryLinkDoc | SidebarItemCategoryLinkGeneratedIndex;
|
|
66
66
|
export declare type SidebarItemCategoryConfig = Expand<Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
|
|
67
|
-
items: SidebarItemConfig[];
|
|
67
|
+
items: SidebarCategoriesShorthand | SidebarItemConfig[];
|
|
68
68
|
link?: SidebarItemCategoryLinkConfig;
|
|
69
69
|
}>;
|
|
70
70
|
export declare type SidebarCategoriesShorthand = {
|
|
71
|
-
[sidebarCategory: string]: SidebarItemConfig[];
|
|
71
|
+
[sidebarCategory: string]: SidebarCategoriesShorthand | SidebarItemConfig[];
|
|
72
72
|
};
|
|
73
73
|
export declare type SidebarItemConfig = SidebarItemDoc | SidebarItemHtml | SidebarItemLink | SidebarItemAutogenerated | SidebarItemCategoryConfig | string | SidebarCategoriesShorthand;
|
|
74
74
|
export declare type SidebarConfig = SidebarCategoriesShorthand | SidebarItemConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4549",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/logger": "0.0.0-
|
|
28
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4549",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4549",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4549",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4549",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4549",
|
|
31
31
|
"combine-promises": "^1.1.0",
|
|
32
32
|
"fs-extra": "^10.0.0",
|
|
33
33
|
"import-fresh": "^3.2.2",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"webpack": "^5.68.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
44
|
-
"@docusaurus/types": "0.0.0-
|
|
43
|
+
"@docusaurus/module-type-aliases": "0.0.0-4549",
|
|
44
|
+
"@docusaurus/types": "0.0.0-4549",
|
|
45
45
|
"@types/js-yaml": "^4.0.0",
|
|
46
46
|
"@types/picomatch": "^2.2.1",
|
|
47
47
|
"commander": "^5.1.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=14"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ed41c3cb08710f3a6211b2a17ff658f9dd41f164"
|
|
61
61
|
}
|
|
@@ -50,14 +50,20 @@ export function normalizeItem(
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
if (item.type === 'category') {
|
|
53
|
-
if (typeof item.items !== 'undefined' &&
|
|
53
|
+
if (typeof item.items !== 'undefined' && typeof item.items !== 'object') {
|
|
54
54
|
throw new Error(
|
|
55
|
-
`Invalid category ${JSON.stringify(
|
|
55
|
+
`Invalid category ${JSON.stringify(
|
|
56
|
+
item,
|
|
57
|
+
)}: items must be an array of sidebar items or a category shorthand`,
|
|
56
58
|
);
|
|
57
59
|
}
|
|
58
60
|
const normalizedCategory: NormalizedSidebarItemCategory = {
|
|
59
61
|
...item,
|
|
60
|
-
items: item.items
|
|
62
|
+
items: Array.isArray(item.items)
|
|
63
|
+
? item.items.flatMap((subItem) => normalizeItem(subItem))
|
|
64
|
+
: normalizeCategoriesShorthand(item.items).flatMap((subItem) =>
|
|
65
|
+
normalizeItem(subItem),
|
|
66
|
+
),
|
|
61
67
|
};
|
|
62
68
|
return [normalizedCategory];
|
|
63
69
|
}
|
package/src/sidebars/types.ts
CHANGED
|
@@ -83,13 +83,13 @@ export type SidebarItemCategoryLink =
|
|
|
83
83
|
// The user-given configuration in sidebars.js, before normalization
|
|
84
84
|
export type SidebarItemCategoryConfig = Expand<
|
|
85
85
|
Optional<SidebarItemCategoryBase, 'collapsed' | 'collapsible'> & {
|
|
86
|
-
items: SidebarItemConfig[];
|
|
86
|
+
items: SidebarCategoriesShorthand | SidebarItemConfig[];
|
|
87
87
|
link?: SidebarItemCategoryLinkConfig;
|
|
88
88
|
}
|
|
89
89
|
>;
|
|
90
90
|
|
|
91
91
|
export type SidebarCategoriesShorthand = {
|
|
92
|
-
[sidebarCategory: string]: SidebarItemConfig[];
|
|
92
|
+
[sidebarCategory: string]: SidebarCategoriesShorthand | SidebarItemConfig[];
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export type SidebarItemConfig =
|