@docusaurus/plugin-content-docs 0.0.0-4852 → 0.0.0-4859
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 -3
- package/lib/client/docsClientUtils.js +8 -10
- package/lib/client/index.d.ts +7 -7
- package/lib/client/index.js +22 -26
- package/package.json +9 -9
- package/src/client/docsClientUtils.ts +9 -11
- package/src/client/index.ts +27 -33
- package/src/plugin-content-docs.d.ts +24 -55
|
@@ -10,6 +10,6 @@ export declare function getActivePlugin(allPluginData: {
|
|
|
10
10
|
[pluginId: string]: GlobalPluginData;
|
|
11
11
|
}, pathname: string, options?: UseDataOptions): ActivePlugin | undefined;
|
|
12
12
|
export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
13
|
+
export declare function getActiveVersion(data: GlobalPluginData, pathname: string): GlobalVersion | undefined;
|
|
14
|
+
export declare function getActiveDocContext(data: GlobalPluginData, pathname: string): ActiveDocContext;
|
|
15
|
+
export declare function getDocVersionSuggestions(data: GlobalPluginData, pathname: string): DocVersionSuggestions;
|
|
@@ -34,9 +34,7 @@ function getActivePlugin(allPluginData, pathname, options = {}) {
|
|
|
34
34
|
exports.getActivePlugin = getActivePlugin;
|
|
35
35
|
const getLatestVersion = (data) => data.versions.find((version) => version.isLast);
|
|
36
36
|
exports.getLatestVersion = getLatestVersion;
|
|
37
|
-
|
|
38
|
-
// because there's no version currently considered as active
|
|
39
|
-
const getActiveVersion = (data, pathname) => {
|
|
37
|
+
function getActiveVersion(data, pathname) {
|
|
40
38
|
const lastVersion = (0, exports.getLatestVersion)(data);
|
|
41
39
|
// Last version is a route like /docs/*,
|
|
42
40
|
// we need to match it last or it would match /docs/version-1.0/* as well
|
|
@@ -49,10 +47,10 @@ const getActiveVersion = (data, pathname) => {
|
|
|
49
47
|
exact: false,
|
|
50
48
|
strict: false,
|
|
51
49
|
}));
|
|
52
|
-
}
|
|
50
|
+
}
|
|
53
51
|
exports.getActiveVersion = getActiveVersion;
|
|
54
|
-
|
|
55
|
-
const activeVersion =
|
|
52
|
+
function getActiveDocContext(data, pathname) {
|
|
53
|
+
const activeVersion = getActiveVersion(data, pathname);
|
|
56
54
|
const activeDoc = activeVersion?.docs.find((doc) => !!(0, router_1.matchPath)(pathname, {
|
|
57
55
|
path: doc.path,
|
|
58
56
|
exact: true,
|
|
@@ -77,12 +75,12 @@ const getActiveDocContext = (data, pathname) => {
|
|
|
77
75
|
activeDoc,
|
|
78
76
|
alternateDocVersions: alternateVersionDocs,
|
|
79
77
|
};
|
|
80
|
-
}
|
|
78
|
+
}
|
|
81
79
|
exports.getActiveDocContext = getActiveDocContext;
|
|
82
|
-
|
|
80
|
+
function getDocVersionSuggestions(data, pathname) {
|
|
83
81
|
const latestVersion = (0, exports.getLatestVersion)(data);
|
|
84
|
-
const activeDocContext =
|
|
82
|
+
const activeDocContext = getActiveDocContext(data, pathname);
|
|
85
83
|
const latestDocSuggestion = activeDocContext?.alternateDocVersions[latestVersion.name];
|
|
86
84
|
return { latestDocSuggestion, latestVersionSuggestion: latestVersion };
|
|
87
|
-
}
|
|
85
|
+
}
|
|
88
86
|
exports.getDocVersionSuggestions = getDocVersionSuggestions;
|
package/lib/client/index.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ export declare const useAllDocsData: () => {
|
|
|
10
10
|
[pluginId: string]: GlobalPluginData;
|
|
11
11
|
};
|
|
12
12
|
export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
13
|
+
export declare function useActivePlugin(options?: UseDataOptions): ActivePlugin | undefined;
|
|
14
|
+
export declare function useActivePluginAndVersion(options?: UseDataOptions): {
|
|
15
15
|
activePlugin: ActivePlugin;
|
|
16
16
|
activeVersion: GlobalVersion | undefined;
|
|
17
17
|
} | undefined;
|
|
18
|
-
export declare
|
|
19
|
-
export declare
|
|
20
|
-
export declare
|
|
21
|
-
export declare
|
|
22
|
-
export declare
|
|
18
|
+
export declare function useVersions(pluginId: string | undefined): GlobalVersion[];
|
|
19
|
+
export declare function useLatestVersion(pluginId: string | undefined): GlobalVersion;
|
|
20
|
+
export declare function useActiveVersion(pluginId: string | undefined): GlobalVersion | undefined;
|
|
21
|
+
export declare function useActiveDocContext(pluginId: string | undefined): ActiveDocContext;
|
|
22
|
+
export declare function useDocVersionSuggestions(pluginId: string | undefined): DocVersionSuggestions;
|
package/lib/client/index.js
CHANGED
|
@@ -23,54 +23,50 @@ const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus
|
|
|
23
23
|
});
|
|
24
24
|
exports.useDocsData = useDocsData;
|
|
25
25
|
// TODO this feature should be provided by docusaurus core
|
|
26
|
-
|
|
26
|
+
function useActivePlugin(options = {}) {
|
|
27
27
|
const data = (0, exports.useAllDocsData)();
|
|
28
28
|
const { pathname } = (0, router_1.useLocation)();
|
|
29
29
|
return (0, docsClientUtils_1.getActivePlugin)(data, pathname, options);
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
31
|
exports.useActivePlugin = useActivePlugin;
|
|
32
|
-
|
|
33
|
-
const activePlugin =
|
|
32
|
+
function useActivePluginAndVersion(options = {}) {
|
|
33
|
+
const activePlugin = useActivePlugin(options);
|
|
34
34
|
const { pathname } = (0, router_1.useLocation)();
|
|
35
|
-
if (activePlugin) {
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
activePlugin,
|
|
39
|
-
activeVersion,
|
|
40
|
-
};
|
|
35
|
+
if (!activePlugin) {
|
|
36
|
+
return undefined;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const activeVersion = (0, docsClientUtils_1.getActiveVersion)(activePlugin.pluginData, pathname);
|
|
39
|
+
return {
|
|
40
|
+
activePlugin,
|
|
41
|
+
activeVersion,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
44
|
exports.useActivePluginAndVersion = useActivePluginAndVersion;
|
|
45
|
-
|
|
46
|
-
const useVersions = (pluginId) => {
|
|
45
|
+
function useVersions(pluginId) {
|
|
47
46
|
const data = (0, exports.useDocsData)(pluginId);
|
|
48
47
|
return data.versions;
|
|
49
|
-
}
|
|
48
|
+
}
|
|
50
49
|
exports.useVersions = useVersions;
|
|
51
|
-
|
|
50
|
+
function useLatestVersion(pluginId) {
|
|
52
51
|
const data = (0, exports.useDocsData)(pluginId);
|
|
53
52
|
return (0, docsClientUtils_1.getLatestVersion)(data);
|
|
54
|
-
}
|
|
53
|
+
}
|
|
55
54
|
exports.useLatestVersion = useLatestVersion;
|
|
56
|
-
|
|
57
|
-
// because there's no version currently considered as active
|
|
58
|
-
const useActiveVersion = (pluginId) => {
|
|
55
|
+
function useActiveVersion(pluginId) {
|
|
59
56
|
const data = (0, exports.useDocsData)(pluginId);
|
|
60
57
|
const { pathname } = (0, router_1.useLocation)();
|
|
61
58
|
return (0, docsClientUtils_1.getActiveVersion)(data, pathname);
|
|
62
|
-
}
|
|
59
|
+
}
|
|
63
60
|
exports.useActiveVersion = useActiveVersion;
|
|
64
|
-
|
|
61
|
+
function useActiveDocContext(pluginId) {
|
|
65
62
|
const data = (0, exports.useDocsData)(pluginId);
|
|
66
63
|
const { pathname } = (0, router_1.useLocation)();
|
|
67
64
|
return (0, docsClientUtils_1.getActiveDocContext)(data, pathname);
|
|
68
|
-
}
|
|
65
|
+
}
|
|
69
66
|
exports.useActiveDocContext = useActiveDocContext;
|
|
70
|
-
|
|
71
|
-
const useDocVersionSuggestions = (pluginId) => {
|
|
67
|
+
function useDocVersionSuggestions(pluginId) {
|
|
72
68
|
const data = (0, exports.useDocsData)(pluginId);
|
|
73
69
|
const { pathname } = (0, router_1.useLocation)();
|
|
74
70
|
return (0, docsClientUtils_1.getDocVersionSuggestions)(data, pathname);
|
|
75
|
-
}
|
|
71
|
+
}
|
|
76
72
|
exports.useDocVersionSuggestions = useDocVersionSuggestions;
|
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-4859",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@docusaurus/core": "0.0.0-
|
|
28
|
-
"@docusaurus/logger": "0.0.0-
|
|
29
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
27
|
+
"@docusaurus/core": "0.0.0-4859",
|
|
28
|
+
"@docusaurus/logger": "0.0.0-4859",
|
|
29
|
+
"@docusaurus/mdx-loader": "0.0.0-4859",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4859",
|
|
31
|
+
"@docusaurus/utils-validation": "0.0.0-4859",
|
|
32
32
|
"combine-promises": "^1.1.0",
|
|
33
33
|
"fs-extra": "^10.0.1",
|
|
34
34
|
"import-fresh": "^3.3.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"webpack": "^5.72.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
44
|
-
"@docusaurus/types": "0.0.0-
|
|
43
|
+
"@docusaurus/module-type-aliases": "0.0.0-4859",
|
|
44
|
+
"@docusaurus/types": "0.0.0-4859",
|
|
45
45
|
"@types/js-yaml": "^4.0.5",
|
|
46
46
|
"@types/picomatch": "^2.3.0",
|
|
47
47
|
"commander": "^5.1.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=14"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2c2a2a24c95862a8d08be5ca1a1f7ff57d41c166"
|
|
61
61
|
}
|
|
@@ -59,12 +59,10 @@ export function getActivePlugin(
|
|
|
59
59
|
export const getLatestVersion = (data: GlobalPluginData): GlobalVersion =>
|
|
60
60
|
data.versions.find((version) => version.isLast)!;
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
// because there's no version currently considered as active
|
|
64
|
-
export const getActiveVersion = (
|
|
62
|
+
export function getActiveVersion(
|
|
65
63
|
data: GlobalPluginData,
|
|
66
64
|
pathname: string,
|
|
67
|
-
): GlobalVersion | undefined
|
|
65
|
+
): GlobalVersion | undefined {
|
|
68
66
|
const lastVersion = getLatestVersion(data);
|
|
69
67
|
// Last version is a route like /docs/*,
|
|
70
68
|
// we need to match it last or it would match /docs/version-1.0/* as well
|
|
@@ -80,12 +78,12 @@ export const getActiveVersion = (
|
|
|
80
78
|
strict: false,
|
|
81
79
|
}),
|
|
82
80
|
);
|
|
83
|
-
}
|
|
81
|
+
}
|
|
84
82
|
|
|
85
|
-
export
|
|
83
|
+
export function getActiveDocContext(
|
|
86
84
|
data: GlobalPluginData,
|
|
87
85
|
pathname: string,
|
|
88
|
-
): ActiveDocContext
|
|
86
|
+
): ActiveDocContext {
|
|
89
87
|
const activeVersion = getActiveVersion(data, pathname);
|
|
90
88
|
const activeDoc = activeVersion?.docs.find(
|
|
91
89
|
(doc) =>
|
|
@@ -119,15 +117,15 @@ export const getActiveDocContext = (
|
|
|
119
117
|
activeDoc,
|
|
120
118
|
alternateDocVersions: alternateVersionDocs,
|
|
121
119
|
};
|
|
122
|
-
}
|
|
120
|
+
}
|
|
123
121
|
|
|
124
|
-
export
|
|
122
|
+
export function getDocVersionSuggestions(
|
|
125
123
|
data: GlobalPluginData,
|
|
126
124
|
pathname: string,
|
|
127
|
-
): DocVersionSuggestions
|
|
125
|
+
): DocVersionSuggestions {
|
|
128
126
|
const latestVersion = getLatestVersion(data);
|
|
129
127
|
const activeDocContext = getActiveDocContext(data, pathname);
|
|
130
128
|
const latestDocSuggestion: GlobalDoc | undefined =
|
|
131
129
|
activeDocContext?.alternateDocVersions[latestVersion.name];
|
|
132
130
|
return {latestDocSuggestion, latestVersionSuggestion: latestVersion};
|
|
133
|
-
}
|
|
131
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -43,67 +43,61 @@ export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
|
|
43
43
|
}) as GlobalPluginData;
|
|
44
44
|
|
|
45
45
|
// TODO this feature should be provided by docusaurus core
|
|
46
|
-
export
|
|
46
|
+
export function useActivePlugin(
|
|
47
47
|
options: UseDataOptions = {},
|
|
48
|
-
): ActivePlugin | undefined
|
|
48
|
+
): ActivePlugin | undefined {
|
|
49
49
|
const data = useAllDocsData();
|
|
50
50
|
const {pathname} = useLocation();
|
|
51
51
|
return getActivePlugin(data, pathname, options);
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
export
|
|
54
|
+
export function useActivePluginAndVersion(
|
|
55
55
|
options: UseDataOptions = {},
|
|
56
56
|
):
|
|
57
|
-
| undefined
|
|
58
|
-
|
|
|
57
|
+
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
58
|
+
| undefined {
|
|
59
59
|
const activePlugin = useActivePlugin(options);
|
|
60
60
|
const {pathname} = useLocation();
|
|
61
|
-
if (activePlugin) {
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
activePlugin,
|
|
65
|
-
activeVersion,
|
|
66
|
-
};
|
|
61
|
+
if (!activePlugin) {
|
|
62
|
+
return undefined;
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
const activeVersion = getActiveVersion(activePlugin.pluginData, pathname);
|
|
65
|
+
return {
|
|
66
|
+
activePlugin,
|
|
67
|
+
activeVersion,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
export const useVersions = (pluginId: string | undefined): GlobalVersion[] => {
|
|
71
|
+
export function useVersions(pluginId: string | undefined): GlobalVersion[] {
|
|
73
72
|
const data = useDocsData(pluginId);
|
|
74
73
|
return data.versions;
|
|
75
|
-
}
|
|
74
|
+
}
|
|
76
75
|
|
|
77
|
-
export
|
|
78
|
-
pluginId: string | undefined,
|
|
79
|
-
): GlobalVersion => {
|
|
76
|
+
export function useLatestVersion(pluginId: string | undefined): GlobalVersion {
|
|
80
77
|
const data = useDocsData(pluginId);
|
|
81
78
|
return getLatestVersion(data);
|
|
82
|
-
}
|
|
79
|
+
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
// because there's no version currently considered as active
|
|
86
|
-
export const useActiveVersion = (
|
|
81
|
+
export function useActiveVersion(
|
|
87
82
|
pluginId: string | undefined,
|
|
88
|
-
): GlobalVersion | undefined
|
|
83
|
+
): GlobalVersion | undefined {
|
|
89
84
|
const data = useDocsData(pluginId);
|
|
90
85
|
const {pathname} = useLocation();
|
|
91
86
|
return getActiveVersion(data, pathname);
|
|
92
|
-
}
|
|
87
|
+
}
|
|
93
88
|
|
|
94
|
-
export
|
|
89
|
+
export function useActiveDocContext(
|
|
95
90
|
pluginId: string | undefined,
|
|
96
|
-
): ActiveDocContext
|
|
91
|
+
): ActiveDocContext {
|
|
97
92
|
const data = useDocsData(pluginId);
|
|
98
93
|
const {pathname} = useLocation();
|
|
99
94
|
return getActiveDocContext(data, pathname);
|
|
100
|
-
}
|
|
95
|
+
}
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
export const useDocVersionSuggestions = (
|
|
97
|
+
export function useDocVersionSuggestions(
|
|
104
98
|
pluginId: string | undefined,
|
|
105
|
-
): DocVersionSuggestions
|
|
99
|
+
): DocVersionSuggestions {
|
|
106
100
|
const data = useDocsData(pluginId);
|
|
107
101
|
const {pathname} = useLocation();
|
|
108
102
|
return getDocVersionSuggestions(data, pathname);
|
|
109
|
-
}
|
|
103
|
+
}
|
|
@@ -496,7 +496,7 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
declare module '@theme/DocItem' {
|
|
499
|
-
import type {
|
|
499
|
+
import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
|
|
500
500
|
import type {
|
|
501
501
|
PropVersionMetadata,
|
|
502
502
|
Assets,
|
|
@@ -514,14 +514,7 @@ declare module '@theme/DocItem' {
|
|
|
514
514
|
export interface Props {
|
|
515
515
|
readonly route: DocumentRoute;
|
|
516
516
|
readonly versionMetadata: PropVersionMetadata;
|
|
517
|
-
readonly content:
|
|
518
|
-
readonly frontMatter: DocFrontMatter;
|
|
519
|
-
readonly metadata: DocMetadata;
|
|
520
|
-
readonly toc: readonly TOCItem[];
|
|
521
|
-
readonly contentTitle: string | undefined;
|
|
522
|
-
readonly assets: Assets;
|
|
523
|
-
(): JSX.Element;
|
|
524
|
-
};
|
|
517
|
+
readonly content: LoadedMDXContent<DocFrontMatter, DocMetadata, Assets>;
|
|
525
518
|
}
|
|
526
519
|
|
|
527
520
|
export default function DocItem(props: Props): JSX.Element;
|
|
@@ -561,56 +554,18 @@ declare module '@theme/DocBreadcrumbs' {
|
|
|
561
554
|
|
|
562
555
|
declare module '@theme/DocPage' {
|
|
563
556
|
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
564
|
-
import type {
|
|
557
|
+
import type {RouteConfigComponentProps} from 'react-router-config';
|
|
558
|
+
import type {Required} from 'utility-types';
|
|
565
559
|
|
|
566
|
-
export interface Props {
|
|
567
|
-
readonly location: {readonly pathname: string};
|
|
560
|
+
export interface Props extends Required<RouteConfigComponentProps, 'route'> {
|
|
568
561
|
readonly versionMetadata: PropVersionMetadata;
|
|
569
|
-
readonly route: {
|
|
570
|
-
readonly path: string;
|
|
571
|
-
readonly component: () => JSX.Element;
|
|
572
|
-
readonly routes: DocumentRoute[];
|
|
573
|
-
};
|
|
574
562
|
}
|
|
575
563
|
|
|
576
564
|
export default function DocPage(props: Props): JSX.Element;
|
|
577
565
|
}
|
|
578
566
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
export interface Props {
|
|
583
|
-
children: ReactNode;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
export default function DocPageLayout(props: Props): JSX.Element;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
declare module '@theme/DocPage/Layout/Aside' {
|
|
590
|
-
import type {Dispatch, SetStateAction} from 'react';
|
|
591
|
-
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
|
|
592
|
-
|
|
593
|
-
export interface Props {
|
|
594
|
-
sidebar: PropSidebar;
|
|
595
|
-
hiddenSidebarContainer: boolean;
|
|
596
|
-
setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
export default function DocPageLayoutAside(props: Props): JSX.Element;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
declare module '@theme/DocPage/Layout/Main' {
|
|
603
|
-
import type {ReactNode} from 'react';
|
|
604
|
-
|
|
605
|
-
export interface Props {
|
|
606
|
-
hiddenSidebarContainer: boolean;
|
|
607
|
-
children: ReactNode;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
export default function DocPageLayoutMain(props: Props): JSX.Element;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// TODO until TS supports exports field... hope it's in 4.6
|
|
567
|
+
// TODO TS only supports reading `exports` in 4.7. We will need to merge the
|
|
568
|
+
// type defs (and JSDoc) here with the implementation after that
|
|
614
569
|
declare module '@docusaurus/plugin-content-docs/client' {
|
|
615
570
|
import type {UseDataOptions} from '@docusaurus/types';
|
|
616
571
|
|
|
@@ -624,6 +579,11 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
624
579
|
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
625
580
|
};
|
|
626
581
|
export type GlobalDoc = {
|
|
582
|
+
/**
|
|
583
|
+
* For generated index pages, this is the `slug`, **not** `permalink`
|
|
584
|
+
* (without base URL). Because slugs have leading slashes but IDs don't,
|
|
585
|
+
* there won't be clashes.
|
|
586
|
+
*/
|
|
627
587
|
id: string;
|
|
628
588
|
path: string;
|
|
629
589
|
sidebar: string | undefined;
|
|
@@ -634,7 +594,8 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
634
594
|
label: string;
|
|
635
595
|
isLast: boolean;
|
|
636
596
|
path: string;
|
|
637
|
-
|
|
597
|
+
/** The doc with `slug: /`, or first doc in first sidebar */
|
|
598
|
+
mainDocId: string;
|
|
638
599
|
docs: GlobalDoc[];
|
|
639
600
|
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
640
601
|
};
|
|
@@ -652,9 +613,9 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
652
613
|
breadcrumbs: boolean;
|
|
653
614
|
};
|
|
654
615
|
export type DocVersionSuggestions = {
|
|
655
|
-
|
|
616
|
+
/** suggest the latest version */
|
|
656
617
|
latestVersionSuggestion: GlobalVersion;
|
|
657
|
-
|
|
618
|
+
/** suggest the same doc, in latest version (if exist) */
|
|
658
619
|
latestDocSuggestion?: GlobalDoc;
|
|
659
620
|
};
|
|
660
621
|
|
|
@@ -668,12 +629,20 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
668
629
|
) =>
|
|
669
630
|
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
670
631
|
| undefined;
|
|
632
|
+
/** Versions are returned ordered (most recent first). */
|
|
671
633
|
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
672
634
|
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
635
|
+
/**
|
|
636
|
+
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
637
|
+
* currently considered as active.
|
|
638
|
+
*/
|
|
673
639
|
export const useActiveVersion: (
|
|
674
640
|
pluginId?: string,
|
|
675
641
|
) => GlobalVersion | undefined;
|
|
676
642
|
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
643
|
+
/**
|
|
644
|
+
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
645
|
+
*/
|
|
677
646
|
export const useDocVersionSuggestions: (
|
|
678
647
|
pluginId?: string,
|
|
679
648
|
) => DocVersionSuggestions;
|