@docusaurus/plugin-content-docs 0.0.0-4425 → 0.0.0-4429
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/globalData.d.ts +2 -1
- package/lib/globalData.js +12 -2
- package/lib/routes.d.ts +2 -1
- package/lib/routes.js +3 -2
- package/lib/sidebars/generator.js +4 -12
- package/package.json +9 -9
- package/src/globalData.ts +18 -2
- package/src/routes.ts +4 -1
- package/src/sidebars/generator.ts +16 -15
package/lib/globalData.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Sidebars } from './sidebars/types';
|
|
8
|
-
import type { DocMetadata, LoadedVersion } from './types';
|
|
8
|
+
import type { CategoryGeneratedIndexMetadata, DocMetadata, LoadedVersion } from './types';
|
|
9
9
|
import type { GlobalVersion, GlobalSidebar, GlobalDoc } from '@docusaurus/plugin-content-docs/client';
|
|
10
10
|
export declare function toGlobalDataDoc(doc: DocMetadata): GlobalDoc;
|
|
11
|
+
export declare function toGlobalDataGeneratedIndex(doc: CategoryGeneratedIndexMetadata): GlobalDoc;
|
|
11
12
|
export declare function toGlobalSidebars(sidebars: Sidebars, version: LoadedVersion): Record<string, GlobalSidebar>;
|
|
12
13
|
export declare function toGlobalDataVersion(version: LoadedVersion): GlobalVersion;
|
package/lib/globalData.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.toGlobalDataVersion = exports.toGlobalSidebars = exports.toGlobalDataDoc = void 0;
|
|
9
|
+
exports.toGlobalDataVersion = exports.toGlobalSidebars = exports.toGlobalDataGeneratedIndex = exports.toGlobalDataDoc = void 0;
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const utils_2 = require("./sidebars/utils");
|
|
@@ -18,6 +18,14 @@ function toGlobalDataDoc(doc) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
exports.toGlobalDataDoc = toGlobalDataDoc;
|
|
21
|
+
function toGlobalDataGeneratedIndex(doc) {
|
|
22
|
+
return {
|
|
23
|
+
id: doc.slug,
|
|
24
|
+
path: doc.permalink,
|
|
25
|
+
sidebar: doc.sidebar,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.toGlobalDataGeneratedIndex = toGlobalDataGeneratedIndex;
|
|
21
29
|
function toGlobalSidebars(sidebars, version) {
|
|
22
30
|
const { getFirstLink } = (0, utils_2.createSidebarsUtils)(sidebars);
|
|
23
31
|
return (0, lodash_1.mapValues)(sidebars, (sidebar, sidebarId) => {
|
|
@@ -43,7 +51,9 @@ function toGlobalDataVersion(version) {
|
|
|
43
51
|
isLast: version.isLast,
|
|
44
52
|
path: version.versionPath,
|
|
45
53
|
mainDocId: version.mainDocId,
|
|
46
|
-
docs: version.docs
|
|
54
|
+
docs: version.docs
|
|
55
|
+
.map(toGlobalDataDoc)
|
|
56
|
+
.concat(version.categoryGeneratedIndices.map(toGlobalDataGeneratedIndex)),
|
|
47
57
|
sidebars: toGlobalSidebars(version.sidebars, version),
|
|
48
58
|
};
|
|
49
59
|
}
|
package/lib/routes.d.ts
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
|
|
8
8
|
import type { DocMetadata, LoadedVersion } from './types';
|
|
9
|
-
export declare function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, }: {
|
|
9
|
+
export declare function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, aliasedSource, }: {
|
|
10
10
|
version: LoadedVersion;
|
|
11
11
|
actions: PluginContentLoadedActions;
|
|
12
12
|
docCategoryGeneratedIndexComponent: string;
|
|
13
|
+
aliasedSource: (str: string) => string;
|
|
13
14
|
}): Promise<RouteConfig[]>;
|
|
14
15
|
export declare function createDocRoutes({ docs, actions, docItemComponent, }: {
|
|
15
16
|
docs: DocMetadata[];
|
package/lib/routes.js
CHANGED
|
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const props_1 = require("./props");
|
|
13
13
|
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
14
|
-
async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, }) {
|
|
14
|
+
async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, aliasedSource, }) {
|
|
15
15
|
const slugs = (0, utils_1.createSlugger)();
|
|
16
16
|
async function createCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
|
|
17
17
|
const { sidebar, title, description, slug, permalink, previous, next, image, keywords, } = categoryGeneratedIndex;
|
|
@@ -34,7 +34,7 @@ async function createCategoryGeneratedIndexRoutes({ version, actions, docCategor
|
|
|
34
34
|
component: docCategoryGeneratedIndexComponent,
|
|
35
35
|
exact: true,
|
|
36
36
|
modules: {
|
|
37
|
-
categoryGeneratedIndex: propData,
|
|
37
|
+
categoryGeneratedIndex: aliasedSource(propData),
|
|
38
38
|
},
|
|
39
39
|
// Same as doc, this sidebar route attribute permits to associate this subpage to the given sidebar
|
|
40
40
|
...(sidebar && { sidebar }),
|
|
@@ -77,6 +77,7 @@ async function createVersionRoutes({ loadedVersion, actions, docItemComponent, d
|
|
|
77
77
|
version,
|
|
78
78
|
actions,
|
|
79
79
|
docCategoryGeneratedIndexComponent,
|
|
80
|
+
aliasedSource,
|
|
80
81
|
}),
|
|
81
82
|
]);
|
|
82
83
|
const routes = [...docRoutes, ...sidebarsRoutes];
|
|
@@ -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-4429",
|
|
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-4429",
|
|
26
|
+
"@docusaurus/logger": "0.0.0-4429",
|
|
27
|
+
"@docusaurus/mdx-loader": "0.0.0-4429",
|
|
28
|
+
"@docusaurus/utils": "0.0.0-4429",
|
|
29
|
+
"@docusaurus/utils-validation": "0.0.0-4429",
|
|
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-4429",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4429",
|
|
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": "138cc67980738455ec85abbc6470cdd02c14bcd5"
|
|
61
61
|
}
|
package/src/globalData.ts
CHANGED
|
@@ -9,7 +9,11 @@ import {mapValues} from 'lodash';
|
|
|
9
9
|
import {normalizeUrl} from '@docusaurus/utils';
|
|
10
10
|
import type {Sidebars} from './sidebars/types';
|
|
11
11
|
import {createSidebarsUtils} from './sidebars/utils';
|
|
12
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
CategoryGeneratedIndexMetadata,
|
|
14
|
+
DocMetadata,
|
|
15
|
+
LoadedVersion,
|
|
16
|
+
} from './types';
|
|
13
17
|
import type {
|
|
14
18
|
GlobalVersion,
|
|
15
19
|
GlobalSidebar,
|
|
@@ -24,6 +28,16 @@ export function toGlobalDataDoc(doc: DocMetadata): GlobalDoc {
|
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
export function toGlobalDataGeneratedIndex(
|
|
32
|
+
doc: CategoryGeneratedIndexMetadata,
|
|
33
|
+
): GlobalDoc {
|
|
34
|
+
return {
|
|
35
|
+
id: doc.slug,
|
|
36
|
+
path: doc.permalink,
|
|
37
|
+
sidebar: doc.sidebar,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
export function toGlobalSidebars(
|
|
28
42
|
sidebars: Sidebars,
|
|
29
43
|
version: LoadedVersion,
|
|
@@ -56,7 +70,9 @@ export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
|
|
|
56
70
|
isLast: version.isLast,
|
|
57
71
|
path: version.versionPath,
|
|
58
72
|
mainDocId: version.mainDocId,
|
|
59
|
-
docs: version.docs
|
|
73
|
+
docs: version.docs
|
|
74
|
+
.map(toGlobalDataDoc)
|
|
75
|
+
.concat(version.categoryGeneratedIndices.map(toGlobalDataGeneratedIndex)),
|
|
60
76
|
sidebars: toGlobalSidebars(version.sidebars, version),
|
|
61
77
|
};
|
|
62
78
|
}
|
package/src/routes.ts
CHANGED
|
@@ -20,10 +20,12 @@ export async function createCategoryGeneratedIndexRoutes({
|
|
|
20
20
|
version,
|
|
21
21
|
actions,
|
|
22
22
|
docCategoryGeneratedIndexComponent,
|
|
23
|
+
aliasedSource,
|
|
23
24
|
}: {
|
|
24
25
|
version: LoadedVersion;
|
|
25
26
|
actions: PluginContentLoadedActions;
|
|
26
27
|
docCategoryGeneratedIndexComponent: string;
|
|
28
|
+
aliasedSource: (str: string) => string;
|
|
27
29
|
}): Promise<RouteConfig[]> {
|
|
28
30
|
const slugs = createSlugger();
|
|
29
31
|
|
|
@@ -69,7 +71,7 @@ export async function createCategoryGeneratedIndexRoutes({
|
|
|
69
71
|
component: docCategoryGeneratedIndexComponent,
|
|
70
72
|
exact: true,
|
|
71
73
|
modules: {
|
|
72
|
-
categoryGeneratedIndex: propData,
|
|
74
|
+
categoryGeneratedIndex: aliasedSource(propData),
|
|
73
75
|
},
|
|
74
76
|
// Same as doc, this sidebar route attribute permits to associate this subpage to the given sidebar
|
|
75
77
|
...(sidebar && {sidebar}),
|
|
@@ -149,6 +151,7 @@ export async function createVersionRoutes({
|
|
|
149
151
|
version,
|
|
150
152
|
actions,
|
|
151
153
|
docCategoryGeneratedIndexComponent,
|
|
154
|
+
aliasedSource,
|
|
152
155
|
}),
|
|
153
156
|
]);
|
|
154
157
|
|
|
@@ -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;
|