@docusaurus/plugin-content-docs 0.0.0-4428 → 0.0.0-4433
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/sidebars/generator.js +4 -12
- package/package.json +9 -9
- package/src/sidebars/generator.ts +16 -15
|
@@ -41,15 +41,8 @@ async function readCategoryMetadataFile(categoryDirPath) {
|
|
|
41
41
|
throw e;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Simpler to use only posix paths for mocking file metadata in tests
|
|
47
|
-
const filePath = (0, utils_1.posixPath)(path_1.default.join(categoryDirPath, `${exports.CategoryMetadataFilenameBase}${ext}`));
|
|
48
|
-
if (await fs_extra_1.default.pathExists(filePath)) {
|
|
49
|
-
return tryReadFile(filePath);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
44
|
+
const filePath = await (0, utils_1.findAsyncSequential)(['.json', '.yml', '.yaml'].map((ext) => (0, utils_1.posixPath)(path_1.default.join(categoryDirPath, `${exports.CategoryMetadataFilenameBase}${ext}`))), fs_extra_1.default.pathExists);
|
|
45
|
+
return filePath ? tryReadFile(filePath) : null;
|
|
53
46
|
}
|
|
54
47
|
// Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
|
|
55
48
|
const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, docs: allDocs, options, item: { dirName: autogenDir }, version, }) => {
|
|
@@ -101,13 +94,12 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, docs: allDocs,
|
|
|
101
94
|
docs.forEach((doc) => {
|
|
102
95
|
const breadcrumb = getRelativeBreadcrumb(doc);
|
|
103
96
|
let currentDir = treeRoot; // We walk down the file's path to generate the fs structure
|
|
104
|
-
|
|
105
|
-
for (const dir of breadcrumb) {
|
|
97
|
+
breadcrumb.forEach((dir) => {
|
|
106
98
|
if (typeof currentDir[dir] === 'undefined') {
|
|
107
99
|
currentDir[dir] = {}; // Create new folder.
|
|
108
100
|
}
|
|
109
101
|
currentDir = currentDir[dir]; // Go into the subdirectory.
|
|
110
|
-
}
|
|
102
|
+
});
|
|
111
103
|
currentDir[`${docIdPrefix}${doc.id}`] = null; // We've walked through the file path. Register the file in this directory.
|
|
112
104
|
});
|
|
113
105
|
return treeRoot;
|
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-4433",
|
|
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-
|
|
26
|
-
"@docusaurus/logger": "0.0.0-
|
|
27
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
28
|
-
"@docusaurus/utils": "0.0.0-
|
|
29
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
25
|
+
"@docusaurus/core": "0.0.0-4433",
|
|
26
|
+
"@docusaurus/logger": "0.0.0-4433",
|
|
27
|
+
"@docusaurus/mdx-loader": "0.0.0-4433",
|
|
28
|
+
"@docusaurus/utils": "0.0.0-4433",
|
|
29
|
+
"@docusaurus/utils-validation": "0.0.0-4433",
|
|
30
30
|
"combine-promises": "^1.1.0",
|
|
31
31
|
"escape-string-regexp": "^4.0.0",
|
|
32
32
|
"fs-extra": "^10.0.0",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"webpack": "^5.61.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
46
|
-
"@docusaurus/types": "0.0.0-
|
|
45
|
+
"@docusaurus/module-type-aliases": "0.0.0-4433",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4433",
|
|
47
47
|
"@types/js-yaml": "^4.0.0",
|
|
48
48
|
"@types/picomatch": "^2.2.1",
|
|
49
49
|
"commander": "^5.1.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=14"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ffbadadb02dbb89e253b79dfb6c06609cae500b5"
|
|
61
61
|
}
|
|
@@ -15,7 +15,11 @@ import type {
|
|
|
15
15
|
SidebarItemCategoryLinkConfig,
|
|
16
16
|
} from './types';
|
|
17
17
|
import {sortBy, last} from 'lodash';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
addTrailingSlash,
|
|
20
|
+
posixPath,
|
|
21
|
+
findAsyncSequential,
|
|
22
|
+
} from '@docusaurus/utils';
|
|
19
23
|
import logger from '@docusaurus/logger';
|
|
20
24
|
import path from 'path';
|
|
21
25
|
import fs from 'fs-extra';
|
|
@@ -76,17 +80,15 @@ async function readCategoryMetadataFile(
|
|
|
76
80
|
throw e;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
83
|
+
const filePath = await findAsyncSequential(
|
|
84
|
+
['.json', '.yml', '.yaml'].map((ext) =>
|
|
85
|
+
posixPath(
|
|
86
|
+
path.join(categoryDirPath, `${CategoryMetadataFilenameBase}${ext}`),
|
|
87
|
+
),
|
|
88
|
+
),
|
|
89
|
+
fs.pathExists,
|
|
90
|
+
);
|
|
91
|
+
return filePath ? tryReadFile(filePath) : null;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
// Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
|
|
@@ -154,13 +156,12 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
|
|
|
154
156
|
docs.forEach((doc) => {
|
|
155
157
|
const breadcrumb = getRelativeBreadcrumb(doc);
|
|
156
158
|
let currentDir = treeRoot; // We walk down the file's path to generate the fs structure
|
|
157
|
-
|
|
158
|
-
for (const dir of breadcrumb) {
|
|
159
|
+
breadcrumb.forEach((dir) => {
|
|
159
160
|
if (typeof currentDir[dir] === 'undefined') {
|
|
160
161
|
currentDir[dir] = {}; // Create new folder.
|
|
161
162
|
}
|
|
162
163
|
currentDir = currentDir[dir]!; // Go into the subdirectory.
|
|
163
|
-
}
|
|
164
|
+
});
|
|
164
165
|
currentDir[`${docIdPrefix}${doc.id}`] = null; // We've walked through the file path. Register the file in this directory.
|
|
165
166
|
});
|
|
166
167
|
return treeRoot;
|