@docusaurus/plugin-content-docs 0.0.0-4536 → 0.0.0-4538

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.
@@ -61,6 +61,32 @@ async function processSidebar(unprocessedSidebar, params) {
61
61
  }
62
62
  async function processItem(item) {
63
63
  if (item.type === 'category') {
64
+ // If the current category doesn't have subitems, we render a normal doc link instead.
65
+ if (item.items.length === 0) {
66
+ if (!item.link) {
67
+ throw new Error(`Sidebar category ${item.label} has neither any subitem nor a link. This makes this item not able to link to anything.`);
68
+ }
69
+ switch (item.link.type) {
70
+ case 'doc':
71
+ return [
72
+ {
73
+ type: 'doc',
74
+ label: item.label,
75
+ id: item.link.id,
76
+ },
77
+ ];
78
+ case 'generated-index':
79
+ return [
80
+ {
81
+ type: 'link',
82
+ label: item.label,
83
+ href: item.link.permalink,
84
+ },
85
+ ];
86
+ default:
87
+ throw new Error('Unexpected sidebar category link type');
88
+ }
89
+ }
64
90
  return [await processCategoryItem(item)];
65
91
  }
66
92
  if (item.type === 'autogenerated') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4536",
3
+ "version": "0.0.0-4538",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/core": "0.0.0-4536",
26
- "@docusaurus/logger": "0.0.0-4536",
27
- "@docusaurus/mdx-loader": "0.0.0-4536",
28
- "@docusaurus/utils": "0.0.0-4536",
29
- "@docusaurus/utils-validation": "0.0.0-4536",
25
+ "@docusaurus/core": "0.0.0-4538",
26
+ "@docusaurus/logger": "0.0.0-4538",
27
+ "@docusaurus/mdx-loader": "0.0.0-4538",
28
+ "@docusaurus/utils": "0.0.0-4538",
29
+ "@docusaurus/utils-validation": "0.0.0-4538",
30
30
  "combine-promises": "^1.1.0",
31
31
  "fs-extra": "^10.0.0",
32
32
  "import-fresh": "^3.2.2",
@@ -39,8 +39,8 @@
39
39
  "webpack": "^5.68.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4536",
43
- "@docusaurus/types": "0.0.0-4536",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4538",
43
+ "@docusaurus/types": "0.0.0-4538",
44
44
  "@types/js-yaml": "^4.0.0",
45
45
  "@types/picomatch": "^2.2.1",
46
46
  "commander": "^5.1.0",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=14"
58
58
  },
59
- "gitHead": "a9d652056b10bf55db1bc1392672752a8b6250a7"
59
+ "gitHead": "3f91acd1af87957eac279e9f19fdf9c48b804160"
60
60
  }
@@ -117,6 +117,34 @@ async function processSidebar(
117
117
  item: NormalizedSidebarItem,
118
118
  ): Promise<SidebarItem[]> {
119
119
  if (item.type === 'category') {
120
+ // If the current category doesn't have subitems, we render a normal doc link instead.
121
+ if (item.items.length === 0) {
122
+ if (!item.link) {
123
+ throw new Error(
124
+ `Sidebar category ${item.label} has neither any subitem nor a link. This makes this item not able to link to anything.`,
125
+ );
126
+ }
127
+ switch (item.link.type) {
128
+ case 'doc':
129
+ return [
130
+ {
131
+ type: 'doc',
132
+ label: item.label,
133
+ id: item.link.id,
134
+ },
135
+ ];
136
+ case 'generated-index':
137
+ return [
138
+ {
139
+ type: 'link',
140
+ label: item.label,
141
+ href: item.link.permalink,
142
+ },
143
+ ];
144
+ default:
145
+ throw new Error('Unexpected sidebar category link type');
146
+ }
147
+ }
120
148
  return [await processCategoryItem(item)];
121
149
  }
122
150
  if (item.type === 'autogenerated') {