@docusaurus/plugin-content-docs 3.0.0-beta.0 → 3.0.0-rc.1
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/cli.js +1 -1
- package/lib/sidebars/index.d.ts +1 -1
- package/lib/sidebars/index.js +10 -4
- package/package.json +10 -11
- package/src/cli.ts +2 -2
- package/src/sidebars/index.ts +15 -4
package/lib/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, vers
|
|
|
21
21
|
// Note: we don't need the sidebars file to be normalized: it's ok to let
|
|
22
22
|
// plugin option changes to impact older, versioned sidebars
|
|
23
23
|
// We don't validate here, assuming the user has already built the version
|
|
24
|
-
const sidebars = await (0, sidebars_1.
|
|
24
|
+
const sidebars = await (0, sidebars_1.loadSidebarsFile)(sidebarPath);
|
|
25
25
|
// Do not create a useless versioned sidebars file if sidebars file is empty
|
|
26
26
|
// or sidebars are disabled/false)
|
|
27
27
|
const shouldCreateVersionedSidebarFile = Object.keys(sidebars).length > 0;
|
package/lib/sidebars/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ import type { SidebarsConfig, Sidebars, SidebarProcessorParams } from './types';
|
|
|
9
9
|
export declare const DefaultSidebars: SidebarsConfig;
|
|
10
10
|
export declare const DisabledSidebars: SidebarsConfig;
|
|
11
11
|
export declare function resolveSidebarPathOption(siteDir: string, sidebarPathOption: PluginOptions['sidebarPath']): PluginOptions['sidebarPath'];
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function loadSidebarsFile(sidebarFilePath: string | false | undefined): Promise<SidebarsConfig>;
|
|
13
13
|
export declare function loadSidebars(sidebarFilePath: string | false | undefined, options: SidebarProcessorParams): Promise<Sidebars>;
|
package/lib/sidebars/index.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.loadSidebars = exports.
|
|
9
|
+
exports.loadSidebars = exports.loadSidebarsFile = exports.resolveSidebarPathOption = exports.DisabledSidebars = exports.DefaultSidebars = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -15,7 +15,6 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
17
17
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
18
|
-
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
19
18
|
const validation_1 = require("./validation");
|
|
20
19
|
const normalization_1 = require("./normalization");
|
|
21
20
|
const processor_1 = require("./processor");
|
|
@@ -72,9 +71,16 @@ async function loadSidebarsFileUnsafe(sidebarFilePath) {
|
|
|
72
71
|
return exports.DisabledSidebars;
|
|
73
72
|
}
|
|
74
73
|
// We don't want sidebars to be cached because of hot reloading.
|
|
75
|
-
|
|
74
|
+
const module = await (0, utils_1.loadFreshModule)(sidebarFilePath);
|
|
75
|
+
// TODO unsafe, need to refactor and improve validation
|
|
76
|
+
return module;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
async function loadSidebarsFile(sidebarFilePath) {
|
|
79
|
+
const sidebars = await loadSidebarsFileUnsafe(sidebarFilePath);
|
|
80
|
+
// TODO unsafe, need to refactor and improve validation
|
|
81
|
+
return sidebars;
|
|
82
|
+
}
|
|
83
|
+
exports.loadSidebarsFile = loadSidebarsFile;
|
|
78
84
|
async function loadSidebars(sidebarFilePath, options) {
|
|
79
85
|
try {
|
|
80
86
|
const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,17 +35,16 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "3.0.0-
|
|
39
|
-
"@docusaurus/logger": "3.0.0-
|
|
40
|
-
"@docusaurus/mdx-loader": "3.0.0-
|
|
41
|
-
"@docusaurus/module-type-aliases": "3.0.0-
|
|
42
|
-
"@docusaurus/types": "3.0.0-
|
|
43
|
-
"@docusaurus/utils": "3.0.0-
|
|
44
|
-
"@docusaurus/utils-validation": "3.0.0-
|
|
38
|
+
"@docusaurus/core": "3.0.0-rc.1",
|
|
39
|
+
"@docusaurus/logger": "3.0.0-rc.1",
|
|
40
|
+
"@docusaurus/mdx-loader": "3.0.0-rc.1",
|
|
41
|
+
"@docusaurus/module-type-aliases": "3.0.0-rc.1",
|
|
42
|
+
"@docusaurus/types": "3.0.0-rc.1",
|
|
43
|
+
"@docusaurus/utils": "3.0.0-rc.1",
|
|
44
|
+
"@docusaurus/utils-validation": "3.0.0-rc.1",
|
|
45
45
|
"@types/react-router-config": "^5.0.7",
|
|
46
46
|
"combine-promises": "^1.1.0",
|
|
47
47
|
"fs-extra": "^11.1.1",
|
|
48
|
-
"import-fresh": "^3.3.0",
|
|
49
48
|
"js-yaml": "^4.1.0",
|
|
50
49
|
"lodash": "^4.17.21",
|
|
51
50
|
"tslib": "^2.6.0",
|
|
@@ -64,7 +63,7 @@
|
|
|
64
63
|
"react-dom": "^18.0.0"
|
|
65
64
|
},
|
|
66
65
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
66
|
+
"node": ">=18.0"
|
|
68
67
|
},
|
|
69
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "a51cc6fd7660d47ea08349f723cec9c017af0b4e"
|
|
70
69
|
}
|
package/src/cli.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
readVersionsFile,
|
|
18
18
|
} from './versions/files';
|
|
19
19
|
import {validateVersionName} from './versions/validation';
|
|
20
|
-
import {
|
|
20
|
+
import {loadSidebarsFile} from './sidebars';
|
|
21
21
|
import {CURRENT_VERSION_NAME} from './constants';
|
|
22
22
|
import type {PluginOptions} from '@docusaurus/plugin-content-docs';
|
|
23
23
|
import type {LoadContext} from '@docusaurus/types';
|
|
@@ -37,7 +37,7 @@ async function createVersionedSidebarFile({
|
|
|
37
37
|
// Note: we don't need the sidebars file to be normalized: it's ok to let
|
|
38
38
|
// plugin option changes to impact older, versioned sidebars
|
|
39
39
|
// We don't validate here, assuming the user has already built the version
|
|
40
|
-
const sidebars = await
|
|
40
|
+
const sidebars = await loadSidebarsFile(sidebarPath);
|
|
41
41
|
|
|
42
42
|
// Do not create a useless versioned sidebars file if sidebars file is empty
|
|
43
43
|
// or sidebars are disabled/false)
|
package/src/sidebars/index.ts
CHANGED
|
@@ -9,10 +9,9 @@ import fs from 'fs-extra';
|
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
import logger from '@docusaurus/logger';
|
|
12
|
-
import {Globby} from '@docusaurus/utils';
|
|
12
|
+
import {loadFreshModule, Globby} from '@docusaurus/utils';
|
|
13
13
|
import Yaml from 'js-yaml';
|
|
14
14
|
import combinePromises from 'combine-promises';
|
|
15
|
-
import importFresh from 'import-fresh';
|
|
16
15
|
import {validateSidebars, validateCategoryMetadataFile} from './validation';
|
|
17
16
|
import {normalizeSidebars} from './normalization';
|
|
18
17
|
import {processSidebars} from './processor';
|
|
@@ -68,7 +67,7 @@ async function readCategoriesMetadata(contentPath: string) {
|
|
|
68
67
|
);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
async function loadSidebarsFileUnsafe(
|
|
72
71
|
sidebarFilePath: string | false | undefined,
|
|
73
72
|
): Promise<SidebarsConfig> {
|
|
74
73
|
// false => no sidebars
|
|
@@ -89,7 +88,19 @@ export async function loadSidebarsFileUnsafe(
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
// We don't want sidebars to be cached because of hot reloading.
|
|
92
|
-
|
|
91
|
+
const module = await loadFreshModule(sidebarFilePath);
|
|
92
|
+
|
|
93
|
+
// TODO unsafe, need to refactor and improve validation
|
|
94
|
+
return module as SidebarsConfig;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function loadSidebarsFile(
|
|
98
|
+
sidebarFilePath: string | false | undefined,
|
|
99
|
+
): Promise<SidebarsConfig> {
|
|
100
|
+
const sidebars = await loadSidebarsFileUnsafe(sidebarFilePath);
|
|
101
|
+
|
|
102
|
+
// TODO unsafe, need to refactor and improve validation
|
|
103
|
+
return sidebars as SidebarsConfig;
|
|
93
104
|
}
|
|
94
105
|
|
|
95
106
|
export async function loadSidebars(
|