@docusaurus/plugin-content-docs 0.0.0-4440 → 0.0.0-4441
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/docFrontMatter.js +1 -0
- package/lib/docs.js +1 -1
- package/lib/sidebars/utils.d.ts +1 -1
- package/lib/sidebars/utils.js +11 -3
- package/lib/sidebars/validation.js +2 -0
- package/lib/types.d.ts +1 -0
- package/package.json +9 -9
- package/src/docFrontMatter.ts +1 -0
- package/src/docs.ts +1 -0
- package/src/sidebars/utils.ts +15 -2
- package/src/sidebars/validation.ts +3 -0
- package/src/types.ts +1 -0
package/lib/docFrontMatter.js
CHANGED
|
@@ -24,6 +24,7 @@ const DocFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
|
|
|
24
24
|
sidebar_label: utils_validation_1.JoiFrontMatter.string(),
|
|
25
25
|
sidebar_position: utils_validation_1.JoiFrontMatter.number(),
|
|
26
26
|
sidebar_class_name: utils_validation_1.JoiFrontMatter.string(),
|
|
27
|
+
displayed_sidebar: utils_validation_1.JoiFrontMatter.string().allow(null),
|
|
27
28
|
tags: utils_validation_1.FrontMatterTagsSchema,
|
|
28
29
|
pagination_label: utils_validation_1.JoiFrontMatter.string(),
|
|
29
30
|
custom_edit_url: utils_validation_1.URISchema.allow('', null),
|
package/lib/docs.js
CHANGED
|
@@ -181,7 +181,7 @@ function addDocNavigation(docsBase, sidebarsUtils, sidebarFilePath) {
|
|
|
181
181
|
sidebarsUtils.checkSidebarsDocIds(docsBase.flatMap(getDocIds), sidebarFilePath);
|
|
182
182
|
// Add sidebar/next/previous to the docs
|
|
183
183
|
function addNavData(doc) {
|
|
184
|
-
const navigation = sidebarsUtils.getDocNavigation(doc.unversionedId, doc.id);
|
|
184
|
+
const navigation = sidebarsUtils.getDocNavigation(doc.unversionedId, doc.id, doc.frontMatter.displayed_sidebar);
|
|
185
185
|
const toNavigationLinkByDocId = (docId, type) => {
|
|
186
186
|
if (!docId) {
|
|
187
187
|
return undefined;
|
package/lib/sidebars/utils.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare type SidebarsUtils = {
|
|
|
24
24
|
sidebars: Sidebars;
|
|
25
25
|
getFirstDocIdOfFirstSidebar: () => string | undefined;
|
|
26
26
|
getSidebarNameByDocId: (docId: string) => string | undefined;
|
|
27
|
-
getDocNavigation: (unversionedId: string, versionedId: string) => SidebarNavigation;
|
|
27
|
+
getDocNavigation: (unversionedId: string, versionedId: string, displayedSidebar: string | null | undefined) => SidebarNavigation;
|
|
28
28
|
getCategoryGeneratedIndexList: () => SidebarItemCategoryWithGeneratedIndex[];
|
|
29
29
|
getCategoryGeneratedIndexNavigation: (categoryGeneratedIndexPermalink: string) => SidebarNavigation;
|
|
30
30
|
getFirstLink: (sidebarId: string) => {
|
package/lib/sidebars/utils.js
CHANGED
|
@@ -104,15 +104,20 @@ function createSidebarsUtils(sidebars) {
|
|
|
104
104
|
next: undefined,
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function getDocNavigation(unversionedId, versionedId) {
|
|
107
|
+
function getDocNavigation(unversionedId, versionedId, displayedSidebar) {
|
|
108
108
|
// TODO legacy id retro-compatibility!
|
|
109
109
|
let docId = unversionedId;
|
|
110
|
-
let sidebarName =
|
|
111
|
-
|
|
110
|
+
let sidebarName = displayedSidebar === undefined
|
|
111
|
+
? getSidebarNameByDocId(docId)
|
|
112
|
+
: displayedSidebar;
|
|
113
|
+
if (sidebarName === undefined) {
|
|
112
114
|
docId = versionedId;
|
|
113
115
|
sidebarName = getSidebarNameByDocId(docId);
|
|
114
116
|
}
|
|
115
117
|
if (sidebarName) {
|
|
118
|
+
if (!sidebarNameToNavigationItems[sidebarName]) {
|
|
119
|
+
throw new Error(`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`);
|
|
120
|
+
}
|
|
116
121
|
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
117
122
|
const currentItemIndex = navigationItems.findIndex((item) => {
|
|
118
123
|
if (item.type === 'doc') {
|
|
@@ -123,6 +128,9 @@ function createSidebarsUtils(sidebars) {
|
|
|
123
128
|
}
|
|
124
129
|
return false;
|
|
125
130
|
});
|
|
131
|
+
if (currentItemIndex === -1) {
|
|
132
|
+
return { sidebarName, next: undefined, previous: undefined };
|
|
133
|
+
}
|
|
126
134
|
const { previous, next } = (0, utils_1.getElementsAround)(navigationItems, currentItemIndex);
|
|
127
135
|
return { sidebarName, previous, next };
|
|
128
136
|
}
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.validateCategoryMetadataFile = exports.validateSidebars = void 0;
|
|
10
10
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
// NOTE: we don't add any default values during validation on purpose!
|
|
13
|
+
// Config types are exposed to users for typechecking and we use the same type in normalization
|
|
12
14
|
const sidebarItemBaseSchema = utils_validation_1.Joi.object({
|
|
13
15
|
className: utils_validation_1.Joi.string(),
|
|
14
16
|
customProps: utils_validation_1.Joi.object().unknown(),
|
package/lib/types.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare type DocFrontMatter = {
|
|
|
51
51
|
sidebar_label?: string;
|
|
52
52
|
sidebar_position?: number;
|
|
53
53
|
sidebar_class_name?: string;
|
|
54
|
+
displayed_sidebar?: string | null;
|
|
54
55
|
pagination_label?: string;
|
|
55
56
|
custom_edit_url?: string | null;
|
|
56
57
|
parse_number_prefixes?: boolean;
|
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-4441",
|
|
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-4441",
|
|
26
|
+
"@docusaurus/logger": "0.0.0-4441",
|
|
27
|
+
"@docusaurus/mdx-loader": "0.0.0-4441",
|
|
28
|
+
"@docusaurus/utils": "0.0.0-4441",
|
|
29
|
+
"@docusaurus/utils-validation": "0.0.0-4441",
|
|
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-4441",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4441",
|
|
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": "43dbd283d8dbcab6ce2f3b1d2ebc0fe0334c77c9"
|
|
61
61
|
}
|
package/src/docFrontMatter.ts
CHANGED
|
@@ -30,6 +30,7 @@ const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
|
|
|
30
30
|
sidebar_label: Joi.string(),
|
|
31
31
|
sidebar_position: Joi.number(),
|
|
32
32
|
sidebar_class_name: Joi.string(),
|
|
33
|
+
displayed_sidebar: Joi.string().allow(null),
|
|
33
34
|
tags: FrontMatterTagsSchema,
|
|
34
35
|
pagination_label: Joi.string(),
|
|
35
36
|
custom_edit_url: URISchema.allow('', null),
|
package/src/docs.ts
CHANGED
package/src/sidebars/utils.ts
CHANGED
|
@@ -131,6 +131,7 @@ export type SidebarsUtils = {
|
|
|
131
131
|
getDocNavigation: (
|
|
132
132
|
unversionedId: string,
|
|
133
133
|
versionedId: string,
|
|
134
|
+
displayedSidebar: string | null | undefined,
|
|
134
135
|
) => SidebarNavigation;
|
|
135
136
|
getCategoryGeneratedIndexList: () => SidebarItemCategoryWithGeneratedIndex[];
|
|
136
137
|
getCategoryGeneratedIndexNavigation: (
|
|
@@ -182,16 +183,25 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|
|
182
183
|
function getDocNavigation(
|
|
183
184
|
unversionedId: string,
|
|
184
185
|
versionedId: string,
|
|
186
|
+
displayedSidebar: string | null | undefined,
|
|
185
187
|
): SidebarNavigation {
|
|
186
188
|
// TODO legacy id retro-compatibility!
|
|
187
189
|
let docId = unversionedId;
|
|
188
|
-
let sidebarName =
|
|
189
|
-
|
|
190
|
+
let sidebarName =
|
|
191
|
+
displayedSidebar === undefined
|
|
192
|
+
? getSidebarNameByDocId(docId)
|
|
193
|
+
: displayedSidebar;
|
|
194
|
+
if (sidebarName === undefined) {
|
|
190
195
|
docId = versionedId;
|
|
191
196
|
sidebarName = getSidebarNameByDocId(docId);
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
if (sidebarName) {
|
|
200
|
+
if (!sidebarNameToNavigationItems[sidebarName]) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
195
205
|
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
|
196
206
|
const currentItemIndex = navigationItems.findIndex((item) => {
|
|
197
207
|
if (item.type === 'doc') {
|
|
@@ -202,6 +212,9 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|
|
202
212
|
}
|
|
203
213
|
return false;
|
|
204
214
|
});
|
|
215
|
+
if (currentItemIndex === -1) {
|
|
216
|
+
return {sidebarName, next: undefined, previous: undefined};
|
|
217
|
+
}
|
|
205
218
|
|
|
206
219
|
const {previous, next} = getElementsAround(
|
|
207
220
|
navigationItems,
|
|
@@ -22,6 +22,9 @@ import type {
|
|
|
22
22
|
import {isCategoriesShorthand} from './utils';
|
|
23
23
|
import type {CategoryMetadataFile} from './generator';
|
|
24
24
|
|
|
25
|
+
// NOTE: we don't add any default values during validation on purpose!
|
|
26
|
+
// Config types are exposed to users for typechecking and we use the same type in normalization
|
|
27
|
+
|
|
25
28
|
const sidebarItemBaseSchema = Joi.object<SidebarItemBase>({
|
|
26
29
|
className: Joi.string(),
|
|
27
30
|
customProps: Joi.object().unknown(),
|
package/src/types.ts
CHANGED