@docusaurus/plugin-content-docs 0.0.0-4776 → 0.0.0-4777
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.
|
@@ -105,9 +105,6 @@ Available doc IDs:
|
|
|
105
105
|
}
|
|
106
106
|
function createCategoryItem(dir, fullPath, folderName) {
|
|
107
107
|
const categoryMetadata = categoriesMetadata[(0, utils_1.posixPath)(path_1.default.join(autogenDir, fullPath))];
|
|
108
|
-
const className = categoryMetadata?.className;
|
|
109
|
-
const customProps = categoryMetadata?.customProps;
|
|
110
|
-
const { filename, numberPrefix } = numberPrefixParser(folderName);
|
|
111
108
|
const allItems = Object.entries(dir).map(([key, content]) => dirToItem(content, key, `${fullPath}/${key}`));
|
|
112
109
|
// Try to match a doc inside the category folder,
|
|
113
110
|
// using the "local id" (myDoc) or "qualified id" (dirName/myDoc)
|
|
@@ -123,34 +120,49 @@ Available doc IDs:
|
|
|
123
120
|
return isCategoryIndex((0, docs_1.toCategoryIndexMatcherParam)(doc));
|
|
124
121
|
});
|
|
125
122
|
}
|
|
126
|
-
function
|
|
123
|
+
// In addition to the ID, this function also retrieves metadata of the
|
|
124
|
+
// linked doc that could be used as fallback values for category metadata
|
|
125
|
+
function getCategoryLinkedDocMetadata() {
|
|
127
126
|
const link = categoryMetadata?.link;
|
|
128
|
-
if (link !== undefined) {
|
|
129
|
-
if (link && link.type === 'doc') {
|
|
130
|
-
return findDocByLocalId(link.id)?.id || getDoc(link.id).id;
|
|
131
|
-
}
|
|
127
|
+
if (link !== undefined && link?.type !== 'doc') {
|
|
132
128
|
// If a link is explicitly specified, we won't apply conventions
|
|
133
129
|
return undefined;
|
|
134
130
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
const id = link
|
|
132
|
+
? findDocByLocalId(link.id)?.id ?? getDoc(link.id).id
|
|
133
|
+
: findConventionalCategoryDocLink()?.id;
|
|
134
|
+
if (!id) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
const doc = getDoc(id);
|
|
138
|
+
return {
|
|
139
|
+
id,
|
|
140
|
+
position: doc.sidebarPosition,
|
|
141
|
+
label: doc.frontMatter.sidebar_label ?? doc.title,
|
|
142
|
+
customProps: doc.frontMatter.sidebar_custom_props,
|
|
143
|
+
className: doc.frontMatter.sidebar_class_name,
|
|
144
|
+
};
|
|
138
145
|
}
|
|
139
|
-
const
|
|
140
|
-
const link =
|
|
146
|
+
const categoryLinkedDoc = getCategoryLinkedDocMetadata();
|
|
147
|
+
const link = categoryLinkedDoc
|
|
141
148
|
? {
|
|
142
149
|
type: 'doc',
|
|
143
|
-
id:
|
|
150
|
+
id: categoryLinkedDoc.id, // We "remap" a potentially "local id" to a "qualified id"
|
|
144
151
|
}
|
|
145
152
|
: categoryMetadata?.link;
|
|
146
153
|
// If a doc is linked, remove it from the category subItems
|
|
147
|
-
const items = allItems.filter((item) => !(item.type === 'doc' && item.id ===
|
|
154
|
+
const items = allItems.filter((item) => !(item.type === 'doc' && item.id === categoryLinkedDoc?.id));
|
|
155
|
+
const className = categoryMetadata?.className ?? categoryLinkedDoc?.className;
|
|
156
|
+
const customProps = categoryMetadata?.customProps ?? categoryLinkedDoc?.customProps;
|
|
157
|
+
const { filename, numberPrefix } = numberPrefixParser(folderName);
|
|
148
158
|
return {
|
|
149
159
|
type: 'category',
|
|
150
|
-
label: categoryMetadata?.label ?? filename,
|
|
160
|
+
label: categoryMetadata?.label ?? categoryLinkedDoc?.label ?? filename,
|
|
151
161
|
collapsible: categoryMetadata?.collapsible,
|
|
152
162
|
collapsed: categoryMetadata?.collapsed,
|
|
153
|
-
position: categoryMetadata?.position ??
|
|
163
|
+
position: categoryMetadata?.position ??
|
|
164
|
+
categoryLinkedDoc?.position ??
|
|
165
|
+
numberPrefix,
|
|
154
166
|
source: folderName,
|
|
155
167
|
...(customProps !== undefined && { customProps }),
|
|
156
168
|
...(className !== undefined && { className }),
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ export declare type CategoryMetadataFile = {
|
|
|
146
146
|
[key: string]: unknown;
|
|
147
147
|
};
|
|
148
148
|
};
|
|
149
|
-
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'unversionedId' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
149
|
+
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'unversionedId' | 'title' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
150
150
|
export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
|
|
151
151
|
export declare type SidebarItemsGeneratorArgs = {
|
|
152
152
|
item: SidebarItemAutogenerated;
|
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-4777",
|
|
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-4777",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4777",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4777",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4777",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4777",
|
|
31
31
|
"combine-promises": "^1.1.0",
|
|
32
32
|
"fs-extra": "^10.0.1",
|
|
33
33
|
"import-fresh": "^3.3.0",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"webpack": "^5.70.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/module-type-aliases": "0.0.0-4777",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4777",
|
|
44
44
|
"@types/js-yaml": "^4.0.5",
|
|
45
45
|
"@types/picomatch": "^2.3.0",
|
|
46
46
|
"commander": "^5.1.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=14"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "245a2a7fe952df111da8cccf7f3b8b8ec389d39e"
|
|
60
60
|
}
|
|
@@ -158,9 +158,6 @@ Available doc IDs:
|
|
|
158
158
|
): WithPosition<NormalizedSidebarItemCategory> {
|
|
159
159
|
const categoryMetadata =
|
|
160
160
|
categoriesMetadata[posixPath(path.join(autogenDir, fullPath))];
|
|
161
|
-
const className = categoryMetadata?.className;
|
|
162
|
-
const customProps = categoryMetadata?.customProps;
|
|
163
|
-
const {filename, numberPrefix} = numberPrefixParser(folderName);
|
|
164
161
|
const allItems = Object.entries(dir).map(([key, content]) =>
|
|
165
162
|
dirToItem(content, key, `${fullPath}/${key}`),
|
|
166
163
|
);
|
|
@@ -184,41 +181,65 @@ Available doc IDs:
|
|
|
184
181
|
});
|
|
185
182
|
}
|
|
186
183
|
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
// In addition to the ID, this function also retrieves metadata of the
|
|
185
|
+
// linked doc that could be used as fallback values for category metadata
|
|
186
|
+
function getCategoryLinkedDocMetadata():
|
|
187
|
+
| {
|
|
188
|
+
id: string;
|
|
189
|
+
position?: number;
|
|
190
|
+
label?: string;
|
|
191
|
+
customProps?: {[key: string]: unknown};
|
|
192
|
+
className?: string;
|
|
192
193
|
}
|
|
194
|
+
| undefined {
|
|
195
|
+
const link = categoryMetadata?.link;
|
|
196
|
+
if (link !== undefined && link?.type !== 'doc') {
|
|
193
197
|
// If a link is explicitly specified, we won't apply conventions
|
|
194
198
|
return undefined;
|
|
195
199
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
const id = link
|
|
201
|
+
? findDocByLocalId(link.id)?.id ?? getDoc(link.id).id
|
|
202
|
+
: findConventionalCategoryDocLink()?.id;
|
|
203
|
+
if (!id) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
const doc = getDoc(id);
|
|
207
|
+
return {
|
|
208
|
+
id,
|
|
209
|
+
position: doc.sidebarPosition,
|
|
210
|
+
label: doc.frontMatter.sidebar_label ?? doc.title,
|
|
211
|
+
customProps: doc.frontMatter.sidebar_custom_props,
|
|
212
|
+
className: doc.frontMatter.sidebar_class_name,
|
|
213
|
+
};
|
|
199
214
|
}
|
|
200
|
-
|
|
201
|
-
const categoryLinkedDocId = getCategoryLinkedDocId();
|
|
202
|
-
|
|
215
|
+
const categoryLinkedDoc = getCategoryLinkedDocMetadata();
|
|
203
216
|
const link: SidebarItemCategoryLinkConfig | null | undefined =
|
|
204
|
-
|
|
217
|
+
categoryLinkedDoc
|
|
205
218
|
? {
|
|
206
219
|
type: 'doc',
|
|
207
|
-
id:
|
|
220
|
+
id: categoryLinkedDoc.id, // We "remap" a potentially "local id" to a "qualified id"
|
|
208
221
|
}
|
|
209
222
|
: categoryMetadata?.link;
|
|
210
|
-
|
|
211
223
|
// If a doc is linked, remove it from the category subItems
|
|
212
224
|
const items = allItems.filter(
|
|
213
|
-
(item) => !(item.type === 'doc' && item.id ===
|
|
225
|
+
(item) => !(item.type === 'doc' && item.id === categoryLinkedDoc?.id),
|
|
214
226
|
);
|
|
215
227
|
|
|
228
|
+
const className =
|
|
229
|
+
categoryMetadata?.className ?? categoryLinkedDoc?.className;
|
|
230
|
+
const customProps =
|
|
231
|
+
categoryMetadata?.customProps ?? categoryLinkedDoc?.customProps;
|
|
232
|
+
const {filename, numberPrefix} = numberPrefixParser(folderName);
|
|
233
|
+
|
|
216
234
|
return {
|
|
217
235
|
type: 'category',
|
|
218
|
-
label: categoryMetadata?.label ?? filename,
|
|
236
|
+
label: categoryMetadata?.label ?? categoryLinkedDoc?.label ?? filename,
|
|
219
237
|
collapsible: categoryMetadata?.collapsible,
|
|
220
238
|
collapsed: categoryMetadata?.collapsed,
|
|
221
|
-
position:
|
|
239
|
+
position:
|
|
240
|
+
categoryMetadata?.position ??
|
|
241
|
+
categoryLinkedDoc?.position ??
|
|
242
|
+
numberPrefix,
|
|
222
243
|
source: folderName,
|
|
223
244
|
...(customProps !== undefined && {customProps}),
|
|
224
245
|
...(className !== undefined && {className}),
|