@docusaurus/plugin-content-docs 3.4.0 → 3.5.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/categoryGeneratedIndex.d.ts +0 -1
- package/lib/categoryGeneratedIndex.js +1 -2
- package/lib/cli.d.ts +0 -1
- package/lib/cli.js +1 -2
- package/lib/client/doc.d.ts +29 -0
- package/lib/client/doc.js +47 -0
- package/lib/client/docSidebarItemsExpandedState.d.ts +30 -0
- package/lib/client/docSidebarItemsExpandedState.js +27 -0
- package/lib/client/docsClientUtils.js +16 -8
- package/lib/client/docsPreferredVersion.d.ts +29 -0
- package/lib/client/docsPreferredVersion.js +124 -0
- package/lib/client/docsSearch.d.ts +19 -0
- package/lib/client/docsSearch.js +39 -0
- package/lib/client/docsSearch.test.d.ts +7 -0
- package/lib/client/docsSearch.test.js +12 -0
- package/lib/client/docsSidebar.d.ts +25 -0
- package/lib/client/docsSidebar.js +29 -0
- package/lib/client/docsUtils.d.ts +106 -0
- package/lib/client/docsUtils.js +273 -0
- package/lib/client/docsVersion.d.ts +19 -0
- package/lib/client/docsVersion.js +25 -0
- package/lib/client/index.d.ts +8 -0
- package/lib/client/index.js +8 -0
- package/lib/docs.d.ts +0 -1
- package/lib/docs.js +8 -8
- package/lib/frontMatter.d.ts +0 -1
- package/lib/frontMatter.js +2 -2
- package/lib/globalData.js +1 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +3 -2
- package/lib/numberPrefix.d.ts +0 -1
- package/lib/numberPrefix.js +3 -3
- package/lib/options.d.ts +0 -1
- package/lib/options.js +4 -2
- package/lib/props.d.ts +0 -1
- package/lib/props.js +5 -6
- package/lib/routes.d.ts +0 -1
- package/lib/routes.js +2 -3
- package/lib/sidebars/generator.js +3 -0
- package/lib/sidebars/index.d.ts +0 -1
- package/lib/sidebars/index.js +4 -4
- package/lib/sidebars/normalization.js +2 -3
- package/lib/sidebars/postProcessor.js +1 -2
- package/lib/sidebars/processor.js +1 -2
- package/lib/sidebars/types.d.ts +1 -1
- package/lib/sidebars/utils.d.ts +0 -1
- package/lib/sidebars/utils.js +13 -14
- package/lib/sidebars/validation.js +3 -3
- package/lib/slug.d.ts +0 -1
- package/lib/slug.js +1 -1
- package/lib/translations.d.ts +0 -1
- package/lib/translations.js +2 -3
- package/lib/types.d.ts +0 -1
- package/lib/versions/files.d.ts +0 -1
- package/lib/versions/files.js +7 -8
- package/lib/versions/index.d.ts +0 -1
- package/lib/versions/index.js +8 -9
- package/lib/versions/validation.d.ts +0 -1
- package/lib/versions/validation.js +3 -4
- package/package.json +11 -10
- package/src/client/doc.tsx +71 -0
- package/src/client/docSidebarItemsExpandedState.tsx +55 -0
- package/src/client/docsClientUtils.ts +17 -8
- package/src/client/docsPreferredVersion.tsx +248 -0
- package/src/client/docsSearch.test.ts +14 -0
- package/src/client/docsSearch.ts +57 -0
- package/src/client/docsSidebar.tsx +50 -0
- package/src/client/docsUtils.tsx +415 -0
- package/src/client/docsVersion.tsx +36 -0
- package/src/client/index.ts +39 -0
- package/src/index.ts +2 -0
- package/src/options.ts +3 -0
- package/src/sidebars/generator.ts +3 -0
- package/src/sidebars/postProcessor.ts +1 -0
- package/src/sidebars/types.ts +1 -0
- package/src/sidebars/validation.ts +1 -0
|
@@ -168,6 +168,9 @@ Available doc IDs:
|
|
|
168
168
|
...(customProps !== undefined && { customProps }),
|
|
169
169
|
...(className !== undefined && { className }),
|
|
170
170
|
items,
|
|
171
|
+
...(categoryMetadata?.description && {
|
|
172
|
+
description: categoryMetadata?.description,
|
|
173
|
+
}),
|
|
171
174
|
...(link && { link }),
|
|
172
175
|
};
|
|
173
176
|
}
|
package/lib/sidebars/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { PluginOptions } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
import type { SidebarsConfig, Sidebars, SidebarProcessorParams } from './types';
|
|
10
9
|
export declare const DefaultSidebars: SidebarsConfig;
|
package/lib/sidebars/index.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.DisabledSidebars = exports.DefaultSidebars = void 0;
|
|
10
|
+
exports.resolveSidebarPathOption = resolveSidebarPathOption;
|
|
11
|
+
exports.loadSidebarsFile = loadSidebarsFile;
|
|
12
|
+
exports.loadSidebars = loadSidebars;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
15
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -34,7 +37,6 @@ function resolveSidebarPathOption(siteDir, sidebarPathOption) {
|
|
|
34
37
|
? path_1.default.resolve(siteDir, sidebarPathOption)
|
|
35
38
|
: sidebarPathOption;
|
|
36
39
|
}
|
|
37
|
-
exports.resolveSidebarPathOption = resolveSidebarPathOption;
|
|
38
40
|
async function readCategoriesMetadata(contentPath) {
|
|
39
41
|
const categoryFiles = await (0, utils_1.Globby)('**/_category_.{json,yml,yaml}', {
|
|
40
42
|
cwd: contentPath,
|
|
@@ -80,7 +82,6 @@ async function loadSidebarsFile(sidebarFilePath) {
|
|
|
80
82
|
// TODO unsafe, need to refactor and improve validation
|
|
81
83
|
return sidebars;
|
|
82
84
|
}
|
|
83
|
-
exports.loadSidebarsFile = loadSidebarsFile;
|
|
84
85
|
async function loadSidebars(sidebarFilePath, options) {
|
|
85
86
|
try {
|
|
86
87
|
const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
|
|
@@ -95,4 +96,3 @@ async function loadSidebars(sidebarFilePath, options) {
|
|
|
95
96
|
throw err;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
exports.loadSidebars = loadSidebars;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.normalizeItem = normalizeItem;
|
|
10
|
+
exports.normalizeSidebars = normalizeSidebars;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -43,7 +44,6 @@ function normalizeItem(item) {
|
|
|
43
44
|
}
|
|
44
45
|
return [item];
|
|
45
46
|
}
|
|
46
|
-
exports.normalizeItem = normalizeItem;
|
|
47
47
|
function normalizeSidebar(sidebar, place) {
|
|
48
48
|
if (!Array.isArray(sidebar) && !(0, utils_1.isCategoriesShorthand)(sidebar)) {
|
|
49
49
|
throw new Error(logger_1.default.interpolate `Invalid sidebar items collection code=${JSON.stringify(sidebar)} in ${place}: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a code=${'type'} property). See url=${'https://docusaurus.io/docs/sidebar/items'} for all valid syntaxes.`);
|
|
@@ -56,4 +56,3 @@ function normalizeSidebar(sidebar, place) {
|
|
|
56
56
|
function normalizeSidebars(sidebars) {
|
|
57
57
|
return lodash_1.default.mapValues(sidebars, (sidebar, id) => normalizeSidebar(sidebar, logger_1.default.interpolate `sidebar name=${id}`));
|
|
58
58
|
}
|
|
59
|
-
exports.normalizeSidebars = normalizeSidebars;
|
|
@@ -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.postProcessSidebars =
|
|
9
|
+
exports.postProcessSidebars = postProcessSidebars;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -77,4 +77,3 @@ function postProcessSidebars(sidebars, params) {
|
|
|
77
77
|
.map((item) => postProcessSidebarItem(item, { ...params, draftIds }))
|
|
78
78
|
.filter((v) => Boolean(v)));
|
|
79
79
|
}
|
|
80
|
-
exports.postProcessSidebars = postProcessSidebars;
|
|
@@ -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.processSidebars =
|
|
9
|
+
exports.processSidebars = processSidebars;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
@@ -75,4 +75,3 @@ async function processSidebars(unprocessedSidebars, categoriesMetadata, params)
|
|
|
75
75
|
(0, validation_1.validateSidebars)(processedSidebars);
|
|
76
76
|
return processedSidebars;
|
|
77
77
|
}
|
|
78
|
-
exports.processSidebars = processSidebars;
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { Optional, Required } from 'utility-types';
|
|
9
8
|
import type { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher, DocMetadataBase, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
import type { Slugger } from '@docusaurus/utils';
|
|
@@ -139,6 +138,7 @@ export type PropSidebarBreadcrumbsItem = PropSidebarItemLink | PropSidebarItemCa
|
|
|
139
138
|
export type CategoryMetadataFile = {
|
|
140
139
|
label?: string;
|
|
141
140
|
position?: number;
|
|
141
|
+
description?: string;
|
|
142
142
|
collapsed?: boolean;
|
|
143
143
|
collapsible?: boolean;
|
|
144
144
|
className?: string;
|
package/lib/sidebars/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { Sidebars, Sidebar, SidebarItem, SidebarItemCategory, SidebarItemLink, SidebarItemDoc, SidebarCategoriesShorthand, SidebarItemConfig, SidebarItemCategoryWithGeneratedIndex, SidebarNavigationItem } from './types';
|
|
9
8
|
import type { DocMetadataBase, PropNavigationLink, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
export declare function isCategoriesShorthand(item: SidebarItemConfig): item is SidebarCategoriesShorthand;
|
package/lib/sidebars/utils.js
CHANGED
|
@@ -6,14 +6,25 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.isCategoriesShorthand = isCategoriesShorthand;
|
|
10
|
+
exports.transformSidebarItems = transformSidebarItems;
|
|
11
|
+
exports.collectSidebarDocItems = collectSidebarDocItems;
|
|
12
|
+
exports.collectSidebarCategories = collectSidebarCategories;
|
|
13
|
+
exports.collectSidebarLinks = collectSidebarLinks;
|
|
14
|
+
exports.collectSidebarRefs = collectSidebarRefs;
|
|
15
|
+
exports.collectSidebarDocIds = collectSidebarDocIds;
|
|
16
|
+
exports.collectSidebarNavigation = collectSidebarNavigation;
|
|
17
|
+
exports.collectSidebarsDocIds = collectSidebarsDocIds;
|
|
18
|
+
exports.collectSidebarsNavigations = collectSidebarsNavigations;
|
|
19
|
+
exports.createSidebarsUtils = createSidebarsUtils;
|
|
20
|
+
exports.toDocNavigationLink = toDocNavigationLink;
|
|
21
|
+
exports.toNavigationLink = toNavigationLink;
|
|
10
22
|
const tslib_1 = require("tslib");
|
|
11
23
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
24
|
const utils_1 = require("@docusaurus/utils");
|
|
13
25
|
function isCategoriesShorthand(item) {
|
|
14
26
|
return typeof item === 'object' && !item.type;
|
|
15
27
|
}
|
|
16
|
-
exports.isCategoriesShorthand = isCategoriesShorthand;
|
|
17
28
|
function transformSidebarItems(sidebar, updateFn) {
|
|
18
29
|
function transformRecursive(item) {
|
|
19
30
|
if (item.type === 'category') {
|
|
@@ -26,7 +37,6 @@ function transformSidebarItems(sidebar, updateFn) {
|
|
|
26
37
|
}
|
|
27
38
|
return sidebar.map(transformRecursive);
|
|
28
39
|
}
|
|
29
|
-
exports.transformSidebarItems = transformSidebarItems;
|
|
30
40
|
/**
|
|
31
41
|
* Flatten sidebar items into a single flat array (containing categories/docs on
|
|
32
42
|
* the same level). Order matters (useful for next/prev nav), top categories
|
|
@@ -46,19 +56,15 @@ function collectSidebarItemsOfType(type, sidebar) {
|
|
|
46
56
|
function collectSidebarDocItems(sidebar) {
|
|
47
57
|
return collectSidebarItemsOfType('doc', sidebar);
|
|
48
58
|
}
|
|
49
|
-
exports.collectSidebarDocItems = collectSidebarDocItems;
|
|
50
59
|
function collectSidebarCategories(sidebar) {
|
|
51
60
|
return collectSidebarItemsOfType('category', sidebar);
|
|
52
61
|
}
|
|
53
|
-
exports.collectSidebarCategories = collectSidebarCategories;
|
|
54
62
|
function collectSidebarLinks(sidebar) {
|
|
55
63
|
return collectSidebarItemsOfType('link', sidebar);
|
|
56
64
|
}
|
|
57
|
-
exports.collectSidebarLinks = collectSidebarLinks;
|
|
58
65
|
function collectSidebarRefs(sidebar) {
|
|
59
66
|
return collectSidebarItemsOfType('ref', sidebar);
|
|
60
67
|
}
|
|
61
|
-
exports.collectSidebarRefs = collectSidebarRefs;
|
|
62
68
|
// /!\ docId order matters for navigation!
|
|
63
69
|
function collectSidebarDocIds(sidebar) {
|
|
64
70
|
return flattenSidebarItems(sidebar).flatMap((item) => {
|
|
@@ -71,7 +77,6 @@ function collectSidebarDocIds(sidebar) {
|
|
|
71
77
|
return [];
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
|
-
exports.collectSidebarDocIds = collectSidebarDocIds;
|
|
75
80
|
function collectSidebarNavigation(sidebar) {
|
|
76
81
|
return flattenSidebarItems(sidebar).flatMap((item) => {
|
|
77
82
|
if (item.type === 'category' && item.link) {
|
|
@@ -83,15 +88,12 @@ function collectSidebarNavigation(sidebar) {
|
|
|
83
88
|
return [];
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
|
-
exports.collectSidebarNavigation = collectSidebarNavigation;
|
|
87
91
|
function collectSidebarsDocIds(sidebars) {
|
|
88
92
|
return lodash_1.default.mapValues(sidebars, collectSidebarDocIds);
|
|
89
93
|
}
|
|
90
|
-
exports.collectSidebarsDocIds = collectSidebarsDocIds;
|
|
91
94
|
function collectSidebarsNavigations(sidebars) {
|
|
92
95
|
return lodash_1.default.mapValues(sidebars, collectSidebarNavigation);
|
|
93
96
|
}
|
|
94
|
-
exports.collectSidebarsNavigations = collectSidebarsNavigations;
|
|
95
97
|
function createSidebarsUtils(sidebars) {
|
|
96
98
|
const sidebarNameToDocIds = collectSidebarsDocIds(sidebars);
|
|
97
99
|
const sidebarNameToNavigationItems = collectSidebarsNavigations(sidebars);
|
|
@@ -293,7 +295,6 @@ Available document ids are:
|
|
|
293
295
|
getFirstLink: (id) => getFirstLink(sidebars[id]),
|
|
294
296
|
};
|
|
295
297
|
}
|
|
296
|
-
exports.createSidebarsUtils = createSidebarsUtils;
|
|
297
298
|
function toDocNavigationLink(doc, options) {
|
|
298
299
|
const { title, permalink, frontMatter: { pagination_label: paginationLabel, sidebar_label: sidebarLabel, }, } = doc;
|
|
299
300
|
return {
|
|
@@ -301,7 +302,6 @@ function toDocNavigationLink(doc, options) {
|
|
|
301
302
|
permalink,
|
|
302
303
|
};
|
|
303
304
|
}
|
|
304
|
-
exports.toDocNavigationLink = toDocNavigationLink;
|
|
305
305
|
function toNavigationLink(navigationItem, docsById) {
|
|
306
306
|
function getDocById(docId) {
|
|
307
307
|
const doc = docsById[docId];
|
|
@@ -325,4 +325,3 @@ function toNavigationLink(navigationItem, docsById) {
|
|
|
325
325
|
sidebarItemLabel: navigationItem?.label,
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
|
-
exports.toNavigationLink = toNavigationLink;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.validateSidebars = validateSidebars;
|
|
10
|
+
exports.validateCategoryMetadataFile = validateCategoryMetadataFile;
|
|
10
11
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
12
|
// NOTE: we don't add any default values during validation on purpose!
|
|
12
13
|
// Config types are exposed to users for typechecking and we use the same type
|
|
@@ -130,9 +131,9 @@ function validateSidebars(sidebars) {
|
|
|
130
131
|
sidebar.forEach(validateSidebarItem);
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
exports.validateSidebars = validateSidebars;
|
|
134
134
|
const categoryMetadataFileSchema = utils_validation_1.Joi.object({
|
|
135
135
|
label: utils_validation_1.Joi.string(),
|
|
136
|
+
description: utils_validation_1.Joi.string(),
|
|
136
137
|
position: utils_validation_1.Joi.number(),
|
|
137
138
|
collapsed: utils_validation_1.Joi.boolean(),
|
|
138
139
|
collapsible: utils_validation_1.Joi.boolean(),
|
|
@@ -147,4 +148,3 @@ function validateCategoryMetadataFile(unsafeContent) {
|
|
|
147
148
|
}
|
|
148
149
|
return value;
|
|
149
150
|
}
|
|
150
|
-
exports.validateCategoryMetadataFile = validateCategoryMetadataFile;
|
package/lib/slug.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { NumberPrefixParser, DocMetadataBase } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
export default function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes, numberPrefixParser, }: {
|
|
10
9
|
baseID: string;
|
package/lib/slug.js
CHANGED
|
@@ -6,6 +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.default = getSlug;
|
|
9
10
|
const utils_1 = require("@docusaurus/utils");
|
|
10
11
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
11
12
|
const numberPrefix_1 = require("./numberPrefix");
|
|
@@ -48,4 +49,3 @@ slug: /my/customDocPath
|
|
|
48
49
|
}
|
|
49
50
|
return ensureValidSlug(computeSlug());
|
|
50
51
|
}
|
|
51
|
-
exports.default = getSlug;
|
package/lib/translations.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { LoadedContent } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
import type { TranslationFile } from '@docusaurus/types';
|
|
10
9
|
export declare function getLoadedContentTranslationFiles(loadedContent: LoadedContent): TranslationFile[];
|
package/lib/translations.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.getLoadedContentTranslationFiles = getLoadedContentTranslationFiles;
|
|
10
|
+
exports.translateLoadedContent = translateLoadedContent;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
13
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -158,11 +159,9 @@ function translateVersions(versions, translationFiles) {
|
|
|
158
159
|
function getLoadedContentTranslationFiles(loadedContent) {
|
|
159
160
|
return getVersionsTranslationFiles(loadedContent.loadedVersions);
|
|
160
161
|
}
|
|
161
|
-
exports.getLoadedContentTranslationFiles = getLoadedContentTranslationFiles;
|
|
162
162
|
function translateLoadedContent(loadedContent, translationFiles) {
|
|
163
163
|
const translationFilesMap = lodash_1.default.keyBy(translationFiles, (f) => f.path);
|
|
164
164
|
return {
|
|
165
165
|
loadedVersions: translateVersions(loadedContent.loadedVersions, translationFilesMap),
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
exports.translateLoadedContent = translateLoadedContent;
|
package/lib/types.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { TagMetadata } from '@docusaurus/utils';
|
|
9
8
|
import type { LoadedVersion, CategoryGeneratedIndexMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
import type { SidebarsUtils } from './sidebars/utils';
|
package/lib/versions/files.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { PluginOptions, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
import type { VersionContext } from './index';
|
|
10
9
|
/** `[siteDir]/community_versioned_docs/version-1.0.0` */
|
package/lib/versions/files.js
CHANGED
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.getVersionDocsDirPath = getVersionDocsDirPath;
|
|
10
|
+
exports.getVersionSidebarsPath = getVersionSidebarsPath;
|
|
11
|
+
exports.getDocsDirPathLocalized = getDocsDirPathLocalized;
|
|
12
|
+
exports.getVersionsFilePath = getVersionsFilePath;
|
|
13
|
+
exports.readVersionsFile = readVersionsFile;
|
|
14
|
+
exports.readVersionNames = readVersionNames;
|
|
15
|
+
exports.getVersionMetadataPaths = getVersionMetadataPaths;
|
|
10
16
|
const tslib_1 = require("tslib");
|
|
11
17
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
18
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -23,12 +29,10 @@ function addPluginIdPrefix(fileOrDir, pluginId) {
|
|
|
23
29
|
function getVersionDocsDirPath(siteDir, pluginId, versionName) {
|
|
24
30
|
return path_1.default.join(siteDir, addPluginIdPrefix(constants_1.VERSIONED_DOCS_DIR, pluginId), `version-${versionName}`);
|
|
25
31
|
}
|
|
26
|
-
exports.getVersionDocsDirPath = getVersionDocsDirPath;
|
|
27
32
|
/** `[siteDir]/community_versioned_sidebars/version-1.0.0-sidebars.json` */
|
|
28
33
|
function getVersionSidebarsPath(siteDir, pluginId, versionName) {
|
|
29
34
|
return path_1.default.join(siteDir, addPluginIdPrefix(constants_1.VERSIONED_SIDEBARS_DIR, pluginId), `version-${versionName}-sidebars.json`);
|
|
30
35
|
}
|
|
31
|
-
exports.getVersionSidebarsPath = getVersionSidebarsPath;
|
|
32
36
|
function getDocsDirPathLocalized({ localizationDir, pluginId, versionName, }) {
|
|
33
37
|
return (0, utils_1.getPluginI18nPath)({
|
|
34
38
|
localizationDir,
|
|
@@ -41,12 +45,10 @@ function getDocsDirPathLocalized({ localizationDir, pluginId, versionName, }) {
|
|
|
41
45
|
],
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
|
-
exports.getDocsDirPathLocalized = getDocsDirPathLocalized;
|
|
45
48
|
/** `community` => `[siteDir]/community_versions.json` */
|
|
46
49
|
function getVersionsFilePath(siteDir, pluginId) {
|
|
47
50
|
return path_1.default.join(siteDir, addPluginIdPrefix(constants_1.VERSIONS_JSON_FILE, pluginId));
|
|
48
51
|
}
|
|
49
|
-
exports.getVersionsFilePath = getVersionsFilePath;
|
|
50
52
|
/**
|
|
51
53
|
* Reads the plugin's respective `versions.json` file, and returns its content.
|
|
52
54
|
*
|
|
@@ -62,7 +64,6 @@ async function readVersionsFile(siteDir, pluginId) {
|
|
|
62
64
|
}
|
|
63
65
|
return null;
|
|
64
66
|
}
|
|
65
|
-
exports.readVersionsFile = readVersionsFile;
|
|
66
67
|
/**
|
|
67
68
|
* Reads the `versions.json` file, and returns an ordered list of version names.
|
|
68
69
|
*
|
|
@@ -98,7 +99,6 @@ async function readVersionNames(siteDir, options) {
|
|
|
98
99
|
}
|
|
99
100
|
return versions;
|
|
100
101
|
}
|
|
101
|
-
exports.readVersionNames = readVersionNames;
|
|
102
102
|
/**
|
|
103
103
|
* Gets the path-related version metadata.
|
|
104
104
|
*
|
|
@@ -138,4 +138,3 @@ Please set the docs "sidebarPath" field in your config file to:
|
|
|
138
138
|
}
|
|
139
139
|
return { contentPath, contentPathLocalized, sidebarFilePath };
|
|
140
140
|
}
|
|
141
|
-
exports.getVersionMetadataPaths = getVersionMetadataPaths;
|
package/lib/versions/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { FullVersion } from '../types';
|
|
9
8
|
import type { LoadContext } from '@docusaurus/types';
|
|
10
9
|
import type { LoadedVersion, PluginOptions, VersionBanner, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
package/lib/versions/index.js
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.getDefaultVersionBanner = getDefaultVersionBanner;
|
|
10
|
+
exports.getVersionBanner = getVersionBanner;
|
|
11
|
+
exports.getVersionBadge = getVersionBadge;
|
|
12
|
+
exports.getVersionNoIndex = getVersionNoIndex;
|
|
13
|
+
exports.filterVersions = filterVersions;
|
|
14
|
+
exports.readVersionsMetadata = readVersionsMetadata;
|
|
15
|
+
exports.toFullVersion = toFullVersion;
|
|
16
|
+
exports.getVersionFromSourceFilePath = getVersionFromSourceFilePath;
|
|
10
17
|
const tslib_1 = require("tslib");
|
|
11
18
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
19
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -55,7 +62,6 @@ function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }
|
|
|
55
62
|
// Older versions: display unmaintained banner
|
|
56
63
|
return 'unmaintained';
|
|
57
64
|
}
|
|
58
|
-
exports.getDefaultVersionBanner = getDefaultVersionBanner;
|
|
59
65
|
function getVersionBanner(context) {
|
|
60
66
|
const { versionName, options } = context;
|
|
61
67
|
const versionBannerOption = options.versions[versionName]?.banner;
|
|
@@ -64,7 +70,6 @@ function getVersionBanner(context) {
|
|
|
64
70
|
}
|
|
65
71
|
return getDefaultVersionBanner(context);
|
|
66
72
|
}
|
|
67
|
-
exports.getVersionBanner = getVersionBanner;
|
|
68
73
|
function getVersionBadge({ versionName, versionNames, options, }) {
|
|
69
74
|
// If site is not versioned or only one version is included
|
|
70
75
|
// we don't show the version badge by default
|
|
@@ -72,11 +77,9 @@ function getVersionBadge({ versionName, versionNames, options, }) {
|
|
|
72
77
|
const defaultVersionBadge = versionNames.length !== 1;
|
|
73
78
|
return options.versions[versionName]?.badge ?? defaultVersionBadge;
|
|
74
79
|
}
|
|
75
|
-
exports.getVersionBadge = getVersionBadge;
|
|
76
80
|
function getVersionNoIndex({ versionName, options, }) {
|
|
77
81
|
return options.versions[versionName]?.noIndex ?? false;
|
|
78
82
|
}
|
|
79
|
-
exports.getVersionNoIndex = getVersionNoIndex;
|
|
80
83
|
function getVersionClassName({ versionName, options, }) {
|
|
81
84
|
const defaultVersionClassName = `docs-version-${versionName}`;
|
|
82
85
|
return options.versions[versionName]?.className ?? defaultVersionClassName;
|
|
@@ -138,7 +141,6 @@ function filterVersions(versionNamesUnfiltered, options) {
|
|
|
138
141
|
}
|
|
139
142
|
return versionNamesUnfiltered;
|
|
140
143
|
}
|
|
141
|
-
exports.filterVersions = filterVersions;
|
|
142
144
|
function getLastVersionName({ versionNames, options, }) {
|
|
143
145
|
return (options.lastVersion ??
|
|
144
146
|
versionNames.find((name) => name !== constants_1.CURRENT_VERSION_NAME) ??
|
|
@@ -158,7 +160,6 @@ async function readVersionsMetadata({ context, options, }) {
|
|
|
158
160
|
})));
|
|
159
161
|
return versionsMetadata;
|
|
160
162
|
}
|
|
161
|
-
exports.readVersionsMetadata = readVersionsMetadata;
|
|
162
163
|
function toFullVersion(version) {
|
|
163
164
|
const sidebarsUtils = (0, utils_2.createSidebarsUtils)(version.sidebars);
|
|
164
165
|
return {
|
|
@@ -170,7 +171,6 @@ function toFullVersion(version) {
|
|
|
170
171
|
}),
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
|
-
exports.toFullVersion = toFullVersion;
|
|
174
174
|
function getVersionFromSourceFilePath(filePath, versionsMetadata) {
|
|
175
175
|
const versionFound = versionsMetadata.find((version) => (0, utils_1.getContentPathList)(version).some((docsDirPath) => filePath.startsWith(docsDirPath)));
|
|
176
176
|
if (!versionFound) {
|
|
@@ -178,4 +178,3 @@ function getVersionFromSourceFilePath(filePath, versionsMetadata) {
|
|
|
178
178
|
}
|
|
179
179
|
return versionFound;
|
|
180
180
|
}
|
|
181
|
-
exports.getVersionFromSourceFilePath = getVersionFromSourceFilePath;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { VersionsOptions } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
export declare function validateVersionName(name: unknown): asserts name is string;
|
|
10
9
|
export declare function validateVersionNames(names: unknown): asserts names is string[];
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.validateVersionName = validateVersionName;
|
|
10
|
+
exports.validateVersionNames = validateVersionNames;
|
|
11
|
+
exports.validateVersionsOptions = validateVersionsOptions;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
14
|
function validateVersionName(name) {
|
|
@@ -29,14 +31,12 @@ function validateVersionName(name) {
|
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
|
-
exports.validateVersionName = validateVersionName;
|
|
33
34
|
function validateVersionNames(names) {
|
|
34
35
|
if (!Array.isArray(names)) {
|
|
35
36
|
throw new Error(`The versions file should contain an array of version names! Found content: ${JSON.stringify(names)}`);
|
|
36
37
|
}
|
|
37
38
|
names.forEach(validateVersionName);
|
|
38
39
|
}
|
|
39
|
-
exports.validateVersionNames = validateVersionNames;
|
|
40
40
|
/**
|
|
41
41
|
* @throws Throws for one of the following invalid options:
|
|
42
42
|
* - `lastVersion` is non-existent
|
|
@@ -68,4 +68,3 @@ function validateVersionsOptions(availableVersionNames, options) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
exports.validateVersionsOptions = validateVersionsOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,14 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "3.
|
|
39
|
-
"@docusaurus/logger": "3.
|
|
40
|
-
"@docusaurus/mdx-loader": "3.
|
|
41
|
-
"@docusaurus/module-type-aliases": "3.
|
|
42
|
-
"@docusaurus/
|
|
43
|
-
"@docusaurus/
|
|
44
|
-
"@docusaurus/utils
|
|
45
|
-
"@docusaurus/utils-
|
|
38
|
+
"@docusaurus/core": "3.5.1",
|
|
39
|
+
"@docusaurus/logger": "3.5.1",
|
|
40
|
+
"@docusaurus/mdx-loader": "3.5.1",
|
|
41
|
+
"@docusaurus/module-type-aliases": "3.5.1",
|
|
42
|
+
"@docusaurus/theme-common": "3.5.1",
|
|
43
|
+
"@docusaurus/types": "3.5.1",
|
|
44
|
+
"@docusaurus/utils": "3.5.1",
|
|
45
|
+
"@docusaurus/utils-common": "3.5.1",
|
|
46
|
+
"@docusaurus/utils-validation": "3.5.1",
|
|
46
47
|
"@types/react-router-config": "^5.0.7",
|
|
47
48
|
"combine-promises": "^1.1.0",
|
|
48
49
|
"fs-extra": "^11.1.1",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"engines": {
|
|
67
68
|
"node": ">=18.0"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5acbc57bd62f3f808ef72007cd67d4c410d13829"
|
|
70
71
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, {useMemo, type ReactNode, useContext} from 'react';
|
|
9
|
+
import {ReactContextError} from '@docusaurus/theme-common/internal';
|
|
10
|
+
import type {PropDocContent} from '@docusaurus/plugin-content-docs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The React context value returned by the `useDoc()` hook.
|
|
14
|
+
* It contains useful data related to the currently browsed doc.
|
|
15
|
+
*/
|
|
16
|
+
export type DocContextValue = Pick<
|
|
17
|
+
PropDocContent,
|
|
18
|
+
'metadata' | 'frontMatter' | 'toc' | 'assets' | 'contentTitle'
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
const Context = React.createContext<DocContextValue | null>(null);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Note: we don't use `PropDoc` as context value on purpose. Metadata is
|
|
25
|
+
* currently stored inside the MDX component, but we may want to change that in
|
|
26
|
+
* the future. This layer is a good opportunity to decouple storage from
|
|
27
|
+
* consuming API, potentially allowing us to provide metadata as both props and
|
|
28
|
+
* route context without duplicating the chunks in the future.
|
|
29
|
+
*/
|
|
30
|
+
function useContextValue(content: PropDocContent): DocContextValue {
|
|
31
|
+
return useMemo(
|
|
32
|
+
() => ({
|
|
33
|
+
metadata: content.metadata,
|
|
34
|
+
frontMatter: content.frontMatter,
|
|
35
|
+
assets: content.assets,
|
|
36
|
+
contentTitle: content.contentTitle,
|
|
37
|
+
toc: content.toc,
|
|
38
|
+
}),
|
|
39
|
+
[content],
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This is a very thin layer around the `content` received from the MDX loader.
|
|
45
|
+
* It provides metadata about the doc to the children tree.
|
|
46
|
+
*/
|
|
47
|
+
export function DocProvider({
|
|
48
|
+
children,
|
|
49
|
+
content,
|
|
50
|
+
}: {
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
content: PropDocContent;
|
|
53
|
+
}): JSX.Element {
|
|
54
|
+
const contextValue = useContextValue(content);
|
|
55
|
+
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns the data of the currently browsed doc. Gives access to the doc's MDX
|
|
60
|
+
* Component, front matter, metadata, TOC, etc. When swizzling a low-level
|
|
61
|
+
* component (e.g. the "Edit this page" link) and you need some extra metadata,
|
|
62
|
+
* you don't have to drill the props all the way through the component tree:
|
|
63
|
+
* simply use this hook instead.
|
|
64
|
+
*/
|
|
65
|
+
export function useDoc(): DocContextValue {
|
|
66
|
+
const doc = useContext(Context);
|
|
67
|
+
if (doc === null) {
|
|
68
|
+
throw new ReactContextError('DocProvider');
|
|
69
|
+
}
|
|
70
|
+
return doc;
|
|
71
|
+
}
|