@docusaurus/plugin-content-docs 0.0.0-4769 → 0.0.0-4772
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/client/docsClientUtils.d.ts +3 -1
- package/lib/client/docsClientUtils.js +3 -3
- package/lib/client/index.d.ts +3 -1
- package/lib/docs.d.ts +3 -1
- package/lib/frontMatter.d.ts +3 -1
- package/lib/sidebars/processor.d.ts +3 -1
- package/lib/sidebars/processor.js +1 -2
- package/lib/sidebars/types.d.ts +12 -5
- package/lib/sidebars/utils.d.ts +9 -3
- package/lib/sidebars/validation.d.ts +3 -1
- package/lib/types.d.ts +6 -2
- package/package.json +9 -9
- package/src/categoryGeneratedIndex.ts +1 -1
- package/src/client/docsClientUtils.ts +3 -3
- package/src/client/index.ts +1 -1
- package/src/deps.d.ts +1 -1
- package/src/docs.ts +1 -1
- package/src/frontMatter.ts +3 -3
- package/src/globalData.ts +1 -1
- package/src/index.ts +1 -2
- package/src/plugin-content-docs.d.ts +5 -5
- package/src/sidebars/processor.ts +3 -10
- package/src/sidebars/types.ts +4 -5
- package/src/sidebars/utils.ts +7 -7
- package/src/sidebars/validation.ts +3 -3
- package/src/translations.ts +3 -3
- package/src/types.ts +2 -2
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { GlobalPluginData, GlobalVersion, GetActivePluginOptions, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
-
export declare function getActivePlugin(
|
|
8
|
+
export declare function getActivePlugin(allPluginData: {
|
|
9
|
+
[pluginId: string]: GlobalPluginData;
|
|
10
|
+
}, pathname: string, options?: GetActivePluginOptions): ActivePlugin | undefined;
|
|
9
11
|
export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
|
|
10
12
|
export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => GlobalVersion | undefined;
|
|
11
13
|
export declare const getActiveDocContext: (data: GlobalPluginData, pathname: string) => ActiveDocContext;
|
|
@@ -12,8 +12,8 @@ const router_1 = require("@docusaurus/router");
|
|
|
12
12
|
// get the data of the plugin that is currently "active"
|
|
13
13
|
// ie the docs of that plugin are currently browsed
|
|
14
14
|
// it is useful to support multiple docs plugin instances
|
|
15
|
-
function getActivePlugin(
|
|
16
|
-
const activeEntry = Object.entries(
|
|
15
|
+
function getActivePlugin(allPluginData, pathname, options = {}) {
|
|
16
|
+
const activeEntry = Object.entries(allPluginData)
|
|
17
17
|
// Route sorting: '/android/foo' should match '/android' instead of '/'
|
|
18
18
|
.sort((a, b) => b[1].path.localeCompare(a[1].path))
|
|
19
19
|
.find(([, pluginData]) => !!(0, router_1.matchPath)(pathname, {
|
|
@@ -25,7 +25,7 @@ function getActivePlugin(allPluginDatas, pathname, options = {}) {
|
|
|
25
25
|
? { pluginId: activeEntry[0], pluginData: activeEntry[1] }
|
|
26
26
|
: undefined;
|
|
27
27
|
if (!activePlugin && options.failfast) {
|
|
28
|
-
throw new Error(`Can't find active docs plugin for "${pathname}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(
|
|
28
|
+
throw new Error(`Can't find active docs plugin for "${pathname}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(allPluginData)
|
|
29
29
|
.map((plugin) => plugin.path)
|
|
30
30
|
.join(', ')}`);
|
|
31
31
|
}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
-
export declare const useAllDocsData: () =>
|
|
8
|
+
export declare const useAllDocsData: () => {
|
|
9
|
+
[pluginId: string]: GlobalPluginData;
|
|
10
|
+
};
|
|
9
11
|
export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
|
|
10
12
|
export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
|
|
11
13
|
export declare const useActivePluginAndVersion: (options?: GetActivePluginOptions) => {
|
package/lib/docs.d.ts
CHANGED
|
@@ -39,5 +39,7 @@ export declare function getDocIds(doc: DocMetadataBase): [string, string];
|
|
|
39
39
|
export declare function createDocsByIdIndex<Doc extends {
|
|
40
40
|
id: string;
|
|
41
41
|
unversionedId: string;
|
|
42
|
-
}>(docs: Doc[]):
|
|
42
|
+
}>(docs: Doc[]): {
|
|
43
|
+
[docId: string]: Doc;
|
|
44
|
+
};
|
|
43
45
|
export {};
|
package/lib/frontMatter.d.ts
CHANGED
|
@@ -5,4 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { DocFrontMatter } from './types';
|
|
8
|
-
export declare function validateDocFrontMatter(frontMatter:
|
|
8
|
+
export declare function validateDocFrontMatter(frontMatter: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}): DocFrontMatter;
|
|
@@ -5,4 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { NormalizedSidebars, ProcessedSidebars, SidebarProcessorParams, CategoryMetadataFile } from './types';
|
|
8
|
-
export declare function processSidebars(unprocessedSidebars: NormalizedSidebars, categoriesMetadata:
|
|
8
|
+
export declare function processSidebars(unprocessedSidebars: NormalizedSidebars, categoriesMetadata: {
|
|
9
|
+
[filePath: string]: CategoryMetadataFile;
|
|
10
|
+
}, params: SidebarProcessorParams): Promise<ProcessedSidebars>;
|
|
@@ -29,7 +29,7 @@ function toSidebarItemsGeneratorVersion(version) {
|
|
|
29
29
|
// Handle the generation of autogenerated sidebar items and other
|
|
30
30
|
// post-processing checks
|
|
31
31
|
async function processSidebar(unprocessedSidebar, categoriesMetadata, params) {
|
|
32
|
-
const { sidebarItemsGenerator, numberPrefixParser, docs, version
|
|
32
|
+
const { sidebarItemsGenerator, numberPrefixParser, docs, version } = params;
|
|
33
33
|
// Just a minor lazy transformation optimization
|
|
34
34
|
const getSidebarItemsGeneratorDocsAndVersion = lodash_1.default.memoize(() => ({
|
|
35
35
|
docs: docs.map(toSidebarItemsGeneratorDoc),
|
|
@@ -42,7 +42,6 @@ async function processSidebar(unprocessedSidebar, categoriesMetadata, params) {
|
|
|
42
42
|
defaultSidebarItemsGenerator: generator_1.DefaultSidebarItemsGenerator,
|
|
43
43
|
isCategoryIndex: docs_1.isCategoryIndex,
|
|
44
44
|
...getSidebarItemsGeneratorDocsAndVersion(),
|
|
45
|
-
options: sidebarOptions,
|
|
46
45
|
categoriesMetadata,
|
|
47
46
|
});
|
|
48
47
|
// Process again... weird but sidebar item generated might generate some
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -8,12 +8,16 @@ import type { Optional, Required } from 'utility-types';
|
|
|
8
8
|
import type { DocMetadataBase, VersionMetadata } from '../types';
|
|
9
9
|
import type { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher } from '@docusaurus/plugin-content-docs';
|
|
10
10
|
import type { Slugger } from '@docusaurus/utils';
|
|
11
|
-
declare type Expand<T extends
|
|
11
|
+
declare type Expand<T extends {
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
}> = {
|
|
12
14
|
[P in keyof T]: T[P];
|
|
13
15
|
};
|
|
14
16
|
export declare type SidebarItemBase = {
|
|
15
17
|
className?: string;
|
|
16
|
-
customProps?:
|
|
18
|
+
customProps?: {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
17
21
|
};
|
|
18
22
|
export declare type SidebarItemDoc = SidebarItemBase & {
|
|
19
23
|
type: 'doc' | 'ref';
|
|
@@ -138,7 +142,9 @@ export declare type CategoryMetadataFile = {
|
|
|
138
142
|
collapsible?: boolean;
|
|
139
143
|
className?: string;
|
|
140
144
|
link?: SidebarItemCategoryLinkConfig | null;
|
|
141
|
-
customProps?:
|
|
145
|
+
customProps?: {
|
|
146
|
+
[key: string]: unknown;
|
|
147
|
+
};
|
|
142
148
|
};
|
|
143
149
|
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'unversionedId' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
144
150
|
export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
|
|
@@ -148,8 +154,9 @@ export declare type SidebarItemsGeneratorArgs = {
|
|
|
148
154
|
docs: SidebarItemsGeneratorDoc[];
|
|
149
155
|
numberPrefixParser: NumberPrefixParser;
|
|
150
156
|
isCategoryIndex: CategoryIndexMatcher;
|
|
151
|
-
categoriesMetadata:
|
|
152
|
-
|
|
157
|
+
categoriesMetadata: {
|
|
158
|
+
[filePath: string]: CategoryMetadataFile;
|
|
159
|
+
};
|
|
153
160
|
};
|
|
154
161
|
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<NormalizedSidebar>;
|
|
155
162
|
export declare type SidebarItemsGeneratorOptionArgs = {
|
package/lib/sidebars/utils.d.ts
CHANGED
|
@@ -13,8 +13,12 @@ export declare function collectSidebarCategories(sidebar: Sidebar): SidebarItemC
|
|
|
13
13
|
export declare function collectSidebarLinks(sidebar: Sidebar): SidebarItemLink[];
|
|
14
14
|
export declare function collectSidebarDocIds(sidebar: Sidebar): string[];
|
|
15
15
|
export declare function collectSidebarNavigation(sidebar: Sidebar): SidebarNavigationItem[];
|
|
16
|
-
export declare function collectSidebarsDocIds(sidebars: Sidebars):
|
|
17
|
-
|
|
16
|
+
export declare function collectSidebarsDocIds(sidebars: Sidebars): {
|
|
17
|
+
[sidebarId: string]: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare function collectSidebarsNavigations(sidebars: Sidebars): {
|
|
20
|
+
[sidebarId: string]: SidebarNavigationItem[];
|
|
21
|
+
};
|
|
18
22
|
export declare type SidebarNavigation = {
|
|
19
23
|
sidebarName: string | undefined;
|
|
20
24
|
previous: SidebarNavigationItem | undefined;
|
|
@@ -45,4 +49,6 @@ export declare type SidebarsUtils = {
|
|
|
45
49
|
};
|
|
46
50
|
export declare function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils;
|
|
47
51
|
export declare function toDocNavigationLink(doc: DocMetadataBase): DocNavLink;
|
|
48
|
-
export declare function toNavigationLink(navigationItem: SidebarNavigationItem | undefined, docsById:
|
|
52
|
+
export declare function toNavigationLink(navigationItem: SidebarNavigationItem | undefined, docsById: {
|
|
53
|
+
[docId: string]: DocMetadataBase;
|
|
54
|
+
}): DocNavLink | undefined;
|
|
@@ -5,5 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { NormalizedSidebars, CategoryMetadataFile } from './types';
|
|
8
|
-
export declare function validateSidebars(sidebars:
|
|
8
|
+
export declare function validateSidebars(sidebars: {
|
|
9
|
+
[sidebarId: string]: unknown;
|
|
10
|
+
}): asserts sidebars is NormalizedSidebars;
|
|
9
11
|
export declare function validateCategoryMetadataFile(unsafeContent: unknown): CategoryMetadataFile;
|
package/lib/types.d.ts
CHANGED
|
@@ -46,7 +46,9 @@ export declare type DocFrontMatter = {
|
|
|
46
46
|
sidebar_label?: string;
|
|
47
47
|
sidebar_position?: number;
|
|
48
48
|
sidebar_class_name?: string;
|
|
49
|
-
sidebar_custom_props?:
|
|
49
|
+
sidebar_custom_props?: {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
50
52
|
displayed_sidebar?: string | null;
|
|
51
53
|
pagination_label?: string;
|
|
52
54
|
custom_edit_url?: string | null;
|
|
@@ -69,7 +71,9 @@ export declare type DocMetadataBase = LastUpdateData & {
|
|
|
69
71
|
sidebarPosition?: number;
|
|
70
72
|
editUrl?: string | null;
|
|
71
73
|
tags: Tag[];
|
|
72
|
-
frontMatter: DocFrontMatter &
|
|
74
|
+
frontMatter: DocFrontMatter & {
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
73
77
|
};
|
|
74
78
|
export declare type DocNavLink = {
|
|
75
79
|
title: string;
|
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-4772",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/logger": "0.0.0-
|
|
28
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4772",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4772",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4772",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4772",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4772",
|
|
31
31
|
"combine-promises": "^1.1.0",
|
|
32
32
|
"fs-extra": "^10.0.1",
|
|
33
33
|
"import-fresh": "^3.3.0",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"webpack": "^5.70.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/module-type-aliases": "0.0.0-4772",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4772",
|
|
44
44
|
"@types/js-yaml": "^4.0.5",
|
|
45
45
|
"@types/picomatch": "^2.3.0",
|
|
46
46
|
"commander": "^5.1.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=14"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "50ef1fb8e19a46e43c122d625c8bff2110546260"
|
|
60
60
|
}
|
|
@@ -17,7 +17,7 @@ function getCategoryGeneratedIndexMetadata({
|
|
|
17
17
|
}: {
|
|
18
18
|
category: SidebarItemCategoryWithGeneratedIndex;
|
|
19
19
|
sidebarsUtils: SidebarsUtils;
|
|
20
|
-
docsById:
|
|
20
|
+
docsById: {[docId: string]: DocMetadataBase};
|
|
21
21
|
}): CategoryGeneratedIndexMetadata {
|
|
22
22
|
const {sidebarName, previous, next} =
|
|
23
23
|
sidebarsUtils.getCategoryGeneratedIndexNavigation(category.link.permalink);
|
|
@@ -23,11 +23,11 @@ import type {
|
|
|
23
23
|
// ie the docs of that plugin are currently browsed
|
|
24
24
|
// it is useful to support multiple docs plugin instances
|
|
25
25
|
export function getActivePlugin(
|
|
26
|
-
|
|
26
|
+
allPluginData: {[pluginId: string]: GlobalPluginData},
|
|
27
27
|
pathname: string,
|
|
28
28
|
options: GetActivePluginOptions = {},
|
|
29
29
|
): ActivePlugin | undefined {
|
|
30
|
-
const activeEntry = Object.entries(
|
|
30
|
+
const activeEntry = Object.entries(allPluginData)
|
|
31
31
|
// Route sorting: '/android/foo' should match '/android' instead of '/'
|
|
32
32
|
.sort((a, b) => b[1].path.localeCompare(a[1].path))
|
|
33
33
|
.find(
|
|
@@ -46,7 +46,7 @@ export function getActivePlugin(
|
|
|
46
46
|
if (!activePlugin && options.failfast) {
|
|
47
47
|
throw new Error(
|
|
48
48
|
`Can't find active docs plugin for "${pathname}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(
|
|
49
|
-
|
|
49
|
+
allPluginData,
|
|
50
50
|
)
|
|
51
51
|
.map((plugin) => plugin.path)
|
|
52
52
|
.join(', ')}`,
|
package/src/client/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ const StableEmptyObject = {};
|
|
|
31
31
|
// Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
|
|
32
32
|
// are still used by the theme. We need a fail-safe fallback when the docs
|
|
33
33
|
// plugin is not in use
|
|
34
|
-
export const useAllDocsData = ():
|
|
34
|
+
export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
|
|
35
35
|
useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
|
|
36
36
|
|
|
37
37
|
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
package/src/deps.d.ts
CHANGED
package/src/docs.ts
CHANGED
|
@@ -424,7 +424,7 @@ export function getDocIds(doc: DocMetadataBase): [string, string] {
|
|
|
424
424
|
// to "id")
|
|
425
425
|
export function createDocsByIdIndex<
|
|
426
426
|
Doc extends {id: string; unversionedId: string},
|
|
427
|
-
>(docs: Doc[]):
|
|
427
|
+
>(docs: Doc[]): {[docId: string]: Doc} {
|
|
428
428
|
return Object.fromEntries(
|
|
429
429
|
docs.flatMap((doc) => [
|
|
430
430
|
[doc.unversionedId, doc],
|
package/src/frontMatter.ts
CHANGED
|
@@ -41,8 +41,8 @@ const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
|
|
|
41
41
|
...FrontMatterTOCHeadingLevels,
|
|
42
42
|
}).unknown();
|
|
43
43
|
|
|
44
|
-
export function validateDocFrontMatter(
|
|
45
|
-
|
|
46
|
-
): DocFrontMatter {
|
|
44
|
+
export function validateDocFrontMatter(frontMatter: {
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}): DocFrontMatter {
|
|
47
47
|
return validateFrontMatter(frontMatter, DocFrontMatterSchema);
|
|
48
48
|
}
|
package/src/globalData.ts
CHANGED
|
@@ -40,7 +40,7 @@ function toGlobalDataGeneratedIndex(
|
|
|
40
40
|
function toGlobalSidebars(
|
|
41
41
|
sidebars: Sidebars,
|
|
42
42
|
version: LoadedVersion,
|
|
43
|
-
):
|
|
43
|
+
): {[sidebarId: string]: GlobalSidebar} {
|
|
44
44
|
const {getFirstLink} = createSidebarsUtils(sidebars);
|
|
45
45
|
return _.mapValues(sidebars, (sidebar, sidebarId) => {
|
|
46
46
|
const firstLink = getFirstLink(sidebarId);
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,6 @@ import type {
|
|
|
56
56
|
PropTagsListPage,
|
|
57
57
|
PluginOptions,
|
|
58
58
|
} from '@docusaurus/plugin-content-docs';
|
|
59
|
-
import type {GlobalPluginData} from '@docusaurus/plugin-content-docs/client';
|
|
60
59
|
import {createSidebarsUtils} from './sidebars/utils';
|
|
61
60
|
import {getCategoryGeneratedIndexMetadataList} from './categoryGeneratedIndex';
|
|
62
61
|
|
|
@@ -293,7 +292,7 @@ export default async function pluginContentDocs(
|
|
|
293
292
|
// TODO tags should be a sub route of the version route
|
|
294
293
|
await Promise.all(loadedVersions.map(createVersionTagsRoutes));
|
|
295
294
|
|
|
296
|
-
setGlobalData
|
|
295
|
+
setGlobalData({
|
|
297
296
|
path: normalizeUrl([baseUrl, options.routeBasePath]),
|
|
298
297
|
versions: loadedVersions.map(toGlobalDataVersion),
|
|
299
298
|
breadcrumbs,
|
|
@@ -68,7 +68,7 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
68
68
|
};
|
|
69
69
|
export type VersionsOptions = {
|
|
70
70
|
lastVersion?: string;
|
|
71
|
-
versions:
|
|
71
|
+
versions: {[versionName: string]: VersionOptions};
|
|
72
72
|
onlyIncludeVersions?: string[];
|
|
73
73
|
};
|
|
74
74
|
export type SidebarOptions = {
|
|
@@ -89,7 +89,7 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
89
89
|
docTagDocListComponent: string;
|
|
90
90
|
docTagsListComponent: string;
|
|
91
91
|
docCategoryGeneratedIndexComponent: string;
|
|
92
|
-
admonitions:
|
|
92
|
+
admonitions: {[key: string]: unknown};
|
|
93
93
|
disableVersioning: boolean;
|
|
94
94
|
includeCurrentVersion: boolean;
|
|
95
95
|
sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
|
|
@@ -282,7 +282,7 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
282
282
|
export type ActiveDocContext = {
|
|
283
283
|
activeVersion?: GlobalVersion;
|
|
284
284
|
activeDoc?: GlobalDoc;
|
|
285
|
-
alternateDocVersions:
|
|
285
|
+
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
286
286
|
};
|
|
287
287
|
export type GlobalDoc = {
|
|
288
288
|
id: string;
|
|
@@ -297,7 +297,7 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
297
297
|
path: string;
|
|
298
298
|
mainDocId: string; // home doc (if docs homepage configured), or first doc
|
|
299
299
|
docs: GlobalDoc[];
|
|
300
|
-
sidebars?:
|
|
300
|
+
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
301
301
|
};
|
|
302
302
|
|
|
303
303
|
export type GlobalSidebarLink = {
|
|
@@ -322,7 +322,7 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
322
322
|
};
|
|
323
323
|
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
|
|
324
324
|
|
|
325
|
-
export const useAllDocsData: () =>
|
|
325
|
+
export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
|
|
326
326
|
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
327
327
|
export const useActivePlugin: (
|
|
328
328
|
options?: GetActivePluginOptions,
|
|
@@ -48,16 +48,10 @@ function toSidebarItemsGeneratorVersion(
|
|
|
48
48
|
// post-processing checks
|
|
49
49
|
async function processSidebar(
|
|
50
50
|
unprocessedSidebar: NormalizedSidebar,
|
|
51
|
-
categoriesMetadata:
|
|
51
|
+
categoriesMetadata: {[filePath: string]: CategoryMetadataFile},
|
|
52
52
|
params: SidebarProcessorParams,
|
|
53
53
|
): Promise<ProcessedSidebar> {
|
|
54
|
-
const {
|
|
55
|
-
sidebarItemsGenerator,
|
|
56
|
-
numberPrefixParser,
|
|
57
|
-
docs,
|
|
58
|
-
version,
|
|
59
|
-
sidebarOptions,
|
|
60
|
-
} = params;
|
|
54
|
+
const {sidebarItemsGenerator, numberPrefixParser, docs, version} = params;
|
|
61
55
|
|
|
62
56
|
// Just a minor lazy transformation optimization
|
|
63
57
|
const getSidebarItemsGeneratorDocsAndVersion = _.memoize(() => ({
|
|
@@ -74,7 +68,6 @@ async function processSidebar(
|
|
|
74
68
|
defaultSidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
|
75
69
|
isCategoryIndex,
|
|
76
70
|
...getSidebarItemsGeneratorDocsAndVersion(),
|
|
77
|
-
options: sidebarOptions,
|
|
78
71
|
categoriesMetadata,
|
|
79
72
|
});
|
|
80
73
|
// Process again... weird but sidebar item generated might generate some
|
|
@@ -113,7 +106,7 @@ async function processSidebar(
|
|
|
113
106
|
|
|
114
107
|
export async function processSidebars(
|
|
115
108
|
unprocessedSidebars: NormalizedSidebars,
|
|
116
|
-
categoriesMetadata:
|
|
109
|
+
categoriesMetadata: {[filePath: string]: CategoryMetadataFile},
|
|
117
110
|
params: SidebarProcessorParams,
|
|
118
111
|
): Promise<ProcessedSidebars> {
|
|
119
112
|
const processedSidebars = await combinePromises(
|
package/src/sidebars/types.ts
CHANGED
|
@@ -15,11 +15,11 @@ import type {
|
|
|
15
15
|
import type {Slugger} from '@docusaurus/utils';
|
|
16
16
|
|
|
17
17
|
// Makes all properties visible when hovering over the type
|
|
18
|
-
type Expand<T extends
|
|
18
|
+
type Expand<T extends {[x: string]: unknown}> = {[P in keyof T]: T[P]};
|
|
19
19
|
|
|
20
20
|
export type SidebarItemBase = {
|
|
21
21
|
className?: string;
|
|
22
|
-
customProps?:
|
|
22
|
+
customProps?: {[key: string]: unknown};
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type SidebarItemDoc = SidebarItemBase & {
|
|
@@ -216,7 +216,7 @@ export type CategoryMetadataFile = {
|
|
|
216
216
|
collapsible?: boolean;
|
|
217
217
|
className?: string;
|
|
218
218
|
link?: SidebarItemCategoryLinkConfig | null;
|
|
219
|
-
customProps?:
|
|
219
|
+
customProps?: {[key: string]: unknown};
|
|
220
220
|
|
|
221
221
|
// TODO should we allow "items" here? how would this work? would an
|
|
222
222
|
// "autogenerated" type be allowed?
|
|
@@ -247,8 +247,7 @@ export type SidebarItemsGeneratorArgs = {
|
|
|
247
247
|
docs: SidebarItemsGeneratorDoc[];
|
|
248
248
|
numberPrefixParser: NumberPrefixParser;
|
|
249
249
|
isCategoryIndex: CategoryIndexMatcher;
|
|
250
|
-
categoriesMetadata:
|
|
251
|
-
options: SidebarOptions;
|
|
250
|
+
categoriesMetadata: {[filePath: string]: CategoryMetadataFile};
|
|
252
251
|
};
|
|
253
252
|
export type SidebarItemsGenerator = (
|
|
254
253
|
generatorArgs: SidebarItemsGeneratorArgs,
|
package/src/sidebars/utils.ts
CHANGED
|
@@ -107,15 +107,15 @@ export function collectSidebarNavigation(
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
export function collectSidebarsDocIds(
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
export function collectSidebarsDocIds(sidebars: Sidebars): {
|
|
111
|
+
[sidebarId: string]: string[];
|
|
112
|
+
} {
|
|
113
113
|
return _.mapValues(sidebars, collectSidebarDocIds);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function collectSidebarsNavigations(
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
export function collectSidebarsNavigations(sidebars: Sidebars): {
|
|
117
|
+
[sidebarId: string]: SidebarNavigationItem[];
|
|
118
|
+
} {
|
|
119
119
|
return _.mapValues(sidebars, collectSidebarNavigation);
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -360,7 +360,7 @@ export function toDocNavigationLink(doc: DocMetadataBase): DocNavLink {
|
|
|
360
360
|
|
|
361
361
|
export function toNavigationLink(
|
|
362
362
|
navigationItem: SidebarNavigationItem | undefined,
|
|
363
|
-
docsById:
|
|
363
|
+
docsById: {[docId: string]: DocMetadataBase},
|
|
364
364
|
): DocNavLink | undefined {
|
|
365
365
|
function getDocById(docId: string) {
|
|
366
366
|
const doc = docsById[docId];
|
|
@@ -149,9 +149,9 @@ function validateSidebarItem(
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export function validateSidebars(
|
|
153
|
-
|
|
154
|
-
): asserts sidebars is NormalizedSidebars {
|
|
152
|
+
export function validateSidebars(sidebars: {
|
|
153
|
+
[sidebarId: string]: unknown;
|
|
154
|
+
}): asserts sidebars is NormalizedSidebars {
|
|
155
155
|
Object.values(sidebars as NormalizedSidebars).forEach((sidebar) => {
|
|
156
156
|
sidebar.forEach(validateSidebarItem);
|
|
157
157
|
});
|
package/src/translations.ts
CHANGED
|
@@ -269,7 +269,7 @@ function getVersionTranslationFiles(version: LoadedVersion): TranslationFiles {
|
|
|
269
269
|
}
|
|
270
270
|
function translateVersion(
|
|
271
271
|
version: LoadedVersion,
|
|
272
|
-
translationFiles:
|
|
272
|
+
translationFiles: {[fileName: string]: TranslationFile},
|
|
273
273
|
): LoadedVersion {
|
|
274
274
|
const versionTranslations =
|
|
275
275
|
translationFiles[getVersionFileName(version.versionName)]!.content;
|
|
@@ -289,7 +289,7 @@ function getVersionsTranslationFiles(
|
|
|
289
289
|
}
|
|
290
290
|
function translateVersions(
|
|
291
291
|
versions: LoadedVersion[],
|
|
292
|
-
translationFiles:
|
|
292
|
+
translationFiles: {[fileName: string]: TranslationFile},
|
|
293
293
|
): LoadedVersion[] {
|
|
294
294
|
return versions.map((version) => translateVersion(version, translationFiles));
|
|
295
295
|
}
|
|
@@ -303,7 +303,7 @@ export function translateLoadedContent(
|
|
|
303
303
|
loadedContent: LoadedContent,
|
|
304
304
|
translationFiles: TranslationFile[],
|
|
305
305
|
): LoadedContent {
|
|
306
|
-
const translationFilesMap:
|
|
306
|
+
const translationFilesMap: {[fileName: string]: TranslationFile} = _.keyBy(
|
|
307
307
|
translationFiles,
|
|
308
308
|
(f) => f.path,
|
|
309
309
|
);
|
package/src/types.ts
CHANGED
|
@@ -59,7 +59,7 @@ export type DocFrontMatter = {
|
|
|
59
59
|
sidebar_label?: string;
|
|
60
60
|
sidebar_position?: number;
|
|
61
61
|
sidebar_class_name?: string;
|
|
62
|
-
sidebar_custom_props?:
|
|
62
|
+
sidebar_custom_props?: {[key: string]: unknown};
|
|
63
63
|
displayed_sidebar?: string | null;
|
|
64
64
|
pagination_label?: string;
|
|
65
65
|
custom_edit_url?: string | null;
|
|
@@ -83,7 +83,7 @@ export type DocMetadataBase = LastUpdateData & {
|
|
|
83
83
|
sidebarPosition?: number;
|
|
84
84
|
editUrl?: string | null;
|
|
85
85
|
tags: Tag[];
|
|
86
|
-
frontMatter: DocFrontMatter &
|
|
86
|
+
frontMatter: DocFrontMatter & {[key: string]: unknown};
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
export type DocNavLink = {
|