@docusaurus/plugin-content-docs 0.0.0-4678 → 0.0.0-4682
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/categoryGeneratedIndex.js +0 -3
- package/lib/sidebars/generator.js +3 -1
- package/lib/sidebars/index.js +1 -1
- package/lib/sidebars/utils.js +3 -6
- package/lib/translations.js +5 -2
- package/package.json +9 -9
- package/src/categoryGeneratedIndex.ts +1 -5
- package/src/docs.ts +1 -1
- package/src/sidebars/generator.ts +3 -3
- package/src/sidebars/index.ts +1 -1
- package/src/sidebars/utils.ts +5 -9
- package/src/translations.ts +6 -2
- package/src/versions.ts +2 -2
|
@@ -11,9 +11,6 @@ const utils_1 = require("./sidebars/utils");
|
|
|
11
11
|
const docs_1 = require("./docs");
|
|
12
12
|
function getCategoryGeneratedIndexMetadata({ category, sidebarsUtils, docsById, }) {
|
|
13
13
|
const { sidebarName, previous, next } = sidebarsUtils.getCategoryGeneratedIndexNavigation(category.link.permalink);
|
|
14
|
-
if (!sidebarName) {
|
|
15
|
-
throw new Error('unexpected');
|
|
16
|
-
}
|
|
17
14
|
return {
|
|
18
15
|
title: category.link.title ?? category.label,
|
|
19
16
|
description: category.link.description,
|
|
@@ -27,7 +27,9 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, isCategoryInde
|
|
|
27
27
|
const getDoc = (docId) => {
|
|
28
28
|
const doc = findDoc(docId);
|
|
29
29
|
if (!doc) {
|
|
30
|
-
throw new Error(`Can't find any doc with
|
|
30
|
+
throw new Error(`Can't find any doc with ID ${docId}.
|
|
31
|
+
Available doc IDs:
|
|
32
|
+
- ${Object.keys(docsById).join('\n- ')}`);
|
|
31
33
|
}
|
|
32
34
|
return doc;
|
|
33
35
|
};
|
package/lib/sidebars/index.js
CHANGED
|
@@ -43,7 +43,7 @@ async function readCategoriesMetadata(contentPath) {
|
|
|
43
43
|
});
|
|
44
44
|
const categoryToFile = lodash_1.default.groupBy(categoryFiles, path_1.default.dirname);
|
|
45
45
|
return (0, combine_promises_1.default)(lodash_1.default.mapValues(categoryToFile, async (files, folder) => {
|
|
46
|
-
const
|
|
46
|
+
const filePath = files[0];
|
|
47
47
|
if (files.length > 1) {
|
|
48
48
|
logger_1.default.warn `There are more than one category metadata files for path=${folder}: ${files.join(', ')}. The behavior is undetermined.`;
|
|
49
49
|
}
|
package/lib/sidebars/utils.js
CHANGED
|
@@ -119,10 +119,10 @@ function createSidebarsUtils(sidebars) {
|
|
|
119
119
|
if (!sidebarName) {
|
|
120
120
|
return emptySidebarNavigation();
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
123
|
+
if (!navigationItems) {
|
|
123
124
|
throw new Error(`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`);
|
|
124
125
|
}
|
|
125
|
-
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
126
126
|
const currentItemIndex = navigationItems.findIndex((item) => {
|
|
127
127
|
if (item.type === 'doc') {
|
|
128
128
|
return item.id === docId;
|
|
@@ -158,10 +158,7 @@ function createSidebarsUtils(sidebars) {
|
|
|
158
158
|
item.link?.type === 'generated-index' &&
|
|
159
159
|
item.link.permalink === categoryGeneratedIndexPermalink);
|
|
160
160
|
}
|
|
161
|
-
const sidebarName = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))
|
|
162
|
-
if (!sidebarName) {
|
|
163
|
-
return emptySidebarNavigation();
|
|
164
|
-
}
|
|
161
|
+
const sidebarName = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))[0];
|
|
165
162
|
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
166
163
|
const currentItemIndex = navigationItems.findIndex(isCurrentCategoryGeneratedIndexItem);
|
|
167
164
|
const { previous, next } = (0, utils_1.getElementsAround)(navigationItems, currentItemIndex);
|
package/lib/translations.js
CHANGED
|
@@ -195,10 +195,13 @@ function getVersionTranslationFiles(version) {
|
|
|
195
195
|
];
|
|
196
196
|
}
|
|
197
197
|
function translateVersion(version, translationFiles) {
|
|
198
|
-
const versionTranslations = translationFiles[getVersionFileName(version.versionName)]
|
|
198
|
+
const versionTranslations = translationFiles[getVersionFileName(version.versionName)]?.content;
|
|
199
|
+
if (!versionTranslations) {
|
|
200
|
+
return version;
|
|
201
|
+
}
|
|
199
202
|
return {
|
|
200
203
|
...version,
|
|
201
|
-
versionLabel: versionTranslations['version.label']?.message,
|
|
204
|
+
versionLabel: versionTranslations['version.label']?.message ?? version.versionLabel,
|
|
202
205
|
sidebars: translateSidebars(version, versionTranslations),
|
|
203
206
|
// docs: translateDocs(version.docs, versionTranslations),
|
|
204
207
|
};
|
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-4682",
|
|
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-4682",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4682",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4682",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4682",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4682",
|
|
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.69.1"
|
|
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-4682",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4682",
|
|
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": "143b48a54a5604d348ff1ad02fd024c8cf9d33a2"
|
|
60
60
|
}
|
|
@@ -21,10 +21,6 @@ function getCategoryGeneratedIndexMetadata({
|
|
|
21
21
|
}): CategoryGeneratedIndexMetadata {
|
|
22
22
|
const {sidebarName, previous, next} =
|
|
23
23
|
sidebarsUtils.getCategoryGeneratedIndexNavigation(category.link.permalink);
|
|
24
|
-
if (!sidebarName) {
|
|
25
|
-
throw new Error('unexpected');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
return {
|
|
29
25
|
title: category.link.title ?? category.label,
|
|
30
26
|
description: category.link.description,
|
|
@@ -32,7 +28,7 @@ function getCategoryGeneratedIndexMetadata({
|
|
|
32
28
|
keywords: category.link.keywords,
|
|
33
29
|
slug: category.link.slug,
|
|
34
30
|
permalink: category.link.permalink,
|
|
35
|
-
sidebar: sidebarName
|
|
31
|
+
sidebar: sidebarName!,
|
|
36
32
|
previous: toNavigationLink(previous, docsById),
|
|
37
33
|
next: toNavigationLink(next, docsById),
|
|
38
34
|
};
|
package/src/docs.ts
CHANGED
|
@@ -60,9 +60,9 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
|
|
|
60
60
|
const doc = findDoc(docId);
|
|
61
61
|
if (!doc) {
|
|
62
62
|
throw new Error(
|
|
63
|
-
`Can't find any doc with
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
`Can't find any doc with ID ${docId}.
|
|
64
|
+
Available doc IDs:
|
|
65
|
+
- ${Object.keys(docsById).join('\n- ')}`,
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
return doc;
|
package/src/sidebars/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ async function readCategoriesMetadata(contentPath: string) {
|
|
|
49
49
|
const categoryToFile = _.groupBy(categoryFiles, path.dirname);
|
|
50
50
|
return combinePromises(
|
|
51
51
|
_.mapValues(categoryToFile, async (files, folder) => {
|
|
52
|
-
const
|
|
52
|
+
const filePath = files[0]!;
|
|
53
53
|
if (files.length > 1) {
|
|
54
54
|
logger.warn`There are more than one category metadata files for path=${folder}: ${files.join(
|
|
55
55
|
', ',
|
package/src/sidebars/utils.ts
CHANGED
|
@@ -201,12 +201,12 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|
|
201
201
|
if (!sidebarName) {
|
|
202
202
|
return emptySidebarNavigation();
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
205
|
+
if (!navigationItems) {
|
|
205
206
|
throw new Error(
|
|
206
207
|
`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`,
|
|
207
208
|
);
|
|
208
209
|
}
|
|
209
|
-
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
210
210
|
const currentItemIndex = navigationItems.findIndex((item) => {
|
|
211
211
|
if (item.type === 'doc') {
|
|
212
212
|
return item.id === docId;
|
|
@@ -258,12 +258,8 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|
|
258
258
|
const sidebarName = Object.entries(sidebarNameToNavigationItems).find(
|
|
259
259
|
([, navigationItems]) =>
|
|
260
260
|
navigationItems.find(isCurrentCategoryGeneratedIndexItem),
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
if (!sidebarName) {
|
|
264
|
-
return emptySidebarNavigation();
|
|
265
|
-
}
|
|
266
|
-
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
261
|
+
)![0];
|
|
262
|
+
const navigationItems = sidebarNameToNavigationItems[sidebarName]!;
|
|
267
263
|
const currentItemIndex = navigationItems.findIndex(
|
|
268
264
|
isCurrentCategoryGeneratedIndexItem,
|
|
269
265
|
);
|
|
@@ -341,7 +337,7 @@ Available document ids are:
|
|
|
341
337
|
getCategoryGeneratedIndexList,
|
|
342
338
|
getCategoryGeneratedIndexNavigation,
|
|
343
339
|
checkSidebarsDocIds,
|
|
344
|
-
getFirstLink: (id) => getFirstLink(sidebars[id]),
|
|
340
|
+
getFirstLink: (id) => getFirstLink(sidebars[id]!),
|
|
345
341
|
};
|
|
346
342
|
}
|
|
347
343
|
|
package/src/translations.ts
CHANGED
|
@@ -274,10 +274,14 @@ function translateVersion(
|
|
|
274
274
|
translationFiles: Record<string, TranslationFile>,
|
|
275
275
|
): LoadedVersion {
|
|
276
276
|
const versionTranslations =
|
|
277
|
-
translationFiles[getVersionFileName(version.versionName)]
|
|
277
|
+
translationFiles[getVersionFileName(version.versionName)]?.content;
|
|
278
|
+
if (!versionTranslations) {
|
|
279
|
+
return version;
|
|
280
|
+
}
|
|
278
281
|
return {
|
|
279
282
|
...version,
|
|
280
|
-
versionLabel:
|
|
283
|
+
versionLabel:
|
|
284
|
+
versionTranslations['version.label']?.message ?? version.versionLabel,
|
|
281
285
|
sidebars: translateSidebars(version, versionTranslations),
|
|
282
286
|
// docs: translateDocs(version.docs, versionTranslations),
|
|
283
287
|
};
|
package/src/versions.ts
CHANGED
|
@@ -464,11 +464,11 @@ Please set the docs "sidebarPath" field in your config file to:
|
|
|
464
464
|
// "last version" is not a very good concept nor api surface
|
|
465
465
|
function getDefaultLastVersionName(versionNames: string[]) {
|
|
466
466
|
if (versionNames.length === 1) {
|
|
467
|
-
return versionNames[0]
|
|
467
|
+
return versionNames[0]!;
|
|
468
468
|
}
|
|
469
469
|
return versionNames.filter(
|
|
470
470
|
(versionName) => versionName !== CURRENT_VERSION_NAME,
|
|
471
|
-
)[0]
|
|
471
|
+
)[0]!;
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
function checkVersionsOptions(
|