@docusaurus/plugin-content-docs 0.0.0-5118 → 0.0.0-5123
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/index.d.ts +60 -1
- package/lib/client/index.js +8 -0
- package/package.json +21 -12
- package/src/client/index.ts +60 -8
- package/src/plugin-content-docs.d.ts +0 -86
package/lib/client/index.d.ts
CHANGED
|
@@ -4,8 +4,59 @@
|
|
|
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
|
-
import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
|
|
8
7
|
import type { UseDataOptions } from '@docusaurus/types';
|
|
8
|
+
export declare type ActivePlugin = {
|
|
9
|
+
pluginId: string;
|
|
10
|
+
pluginData: GlobalPluginData;
|
|
11
|
+
};
|
|
12
|
+
export declare type ActiveDocContext = {
|
|
13
|
+
activeVersion?: GlobalVersion;
|
|
14
|
+
activeDoc?: GlobalDoc;
|
|
15
|
+
alternateDocVersions: {
|
|
16
|
+
[versionName: string]: GlobalDoc;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare type GlobalDoc = {
|
|
20
|
+
/**
|
|
21
|
+
* For generated index pages, this is the `slug`, **not** `permalink`
|
|
22
|
+
* (without base URL). Because slugs have leading slashes but IDs don't,
|
|
23
|
+
* there won't be clashes.
|
|
24
|
+
*/
|
|
25
|
+
id: string;
|
|
26
|
+
path: string;
|
|
27
|
+
sidebar: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare type GlobalVersion = {
|
|
30
|
+
name: string;
|
|
31
|
+
label: string;
|
|
32
|
+
isLast: boolean;
|
|
33
|
+
path: string;
|
|
34
|
+
/** The doc with `slug: /`, or first doc in first sidebar */
|
|
35
|
+
mainDocId: string;
|
|
36
|
+
docs: GlobalDoc[];
|
|
37
|
+
/** Unversioned IDs. In development, this list is empty. */
|
|
38
|
+
draftIds: string[];
|
|
39
|
+
sidebars?: {
|
|
40
|
+
[sidebarId: string]: GlobalSidebar;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare type GlobalSidebar = {
|
|
44
|
+
link?: {
|
|
45
|
+
label: string;
|
|
46
|
+
path: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare type GlobalPluginData = {
|
|
50
|
+
path: string;
|
|
51
|
+
versions: GlobalVersion[];
|
|
52
|
+
breadcrumbs: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare type DocVersionSuggestions = {
|
|
55
|
+
/** Suggest the latest version */
|
|
56
|
+
latestVersionSuggestion: GlobalVersion;
|
|
57
|
+
/** Suggest the same doc, in latest version (if one exists) */
|
|
58
|
+
latestDocSuggestion?: GlobalDoc;
|
|
59
|
+
};
|
|
9
60
|
export declare const useAllDocsData: () => {
|
|
10
61
|
[pluginId: string]: GlobalPluginData;
|
|
11
62
|
};
|
|
@@ -15,8 +66,16 @@ export declare function useActivePluginAndVersion(options?: UseDataOptions): {
|
|
|
15
66
|
activePlugin: ActivePlugin;
|
|
16
67
|
activeVersion: GlobalVersion | undefined;
|
|
17
68
|
} | undefined;
|
|
69
|
+
/** Versions are returned ordered (most recent first). */
|
|
18
70
|
export declare function useVersions(pluginId: string | undefined): GlobalVersion[];
|
|
19
71
|
export declare function useLatestVersion(pluginId: string | undefined): GlobalVersion;
|
|
72
|
+
/**
|
|
73
|
+
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
74
|
+
* currently considered as active.
|
|
75
|
+
*/
|
|
20
76
|
export declare function useActiveVersion(pluginId: string | undefined): GlobalVersion | undefined;
|
|
21
77
|
export declare function useActiveDocContext(pluginId: string | undefined): ActiveDocContext;
|
|
78
|
+
/**
|
|
79
|
+
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
80
|
+
*/
|
|
22
81
|
export declare function useDocVersionSuggestions(pluginId: string | undefined): DocVersionSuggestions;
|
package/lib/client/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export function useActivePluginAndVersion(options = {}) {
|
|
|
34
34
|
activeVersion,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
/** Versions are returned ordered (most recent first). */
|
|
37
38
|
export function useVersions(pluginId) {
|
|
38
39
|
const data = useDocsData(pluginId);
|
|
39
40
|
return data.versions;
|
|
@@ -42,6 +43,10 @@ export function useLatestVersion(pluginId) {
|
|
|
42
43
|
const data = useDocsData(pluginId);
|
|
43
44
|
return getLatestVersion(data);
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
48
|
+
* currently considered as active.
|
|
49
|
+
*/
|
|
45
50
|
export function useActiveVersion(pluginId) {
|
|
46
51
|
const data = useDocsData(pluginId);
|
|
47
52
|
const { pathname } = useLocation();
|
|
@@ -52,6 +57,9 @@ export function useActiveDocContext(pluginId) {
|
|
|
52
57
|
const { pathname } = useLocation();
|
|
53
58
|
return getActiveDocContext(data, pathname);
|
|
54
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
62
|
+
*/
|
|
55
63
|
export function useDocVersionSuggestions(pluginId) {
|
|
56
64
|
const data = useDocsData(pluginId);
|
|
57
65
|
const { pathname } = useLocation();
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5123",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
8
8
|
"./src/*": "./src/*",
|
|
9
|
-
"./client":
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"./client": {
|
|
10
|
+
"type": "./lib/client/index.d.ts",
|
|
11
|
+
"default": "./lib/client/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./server": {
|
|
14
|
+
"type": "./lib/server-export.d.ts",
|
|
15
|
+
"default": "./lib/server-export.js"
|
|
16
|
+
},
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./src/plugin-content-docs.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
}
|
|
12
21
|
},
|
|
13
22
|
"types": "src/plugin-content-docs.d.ts",
|
|
14
23
|
"scripts": {
|
|
@@ -25,13 +34,13 @@
|
|
|
25
34
|
},
|
|
26
35
|
"license": "MIT",
|
|
27
36
|
"dependencies": {
|
|
28
|
-
"@docusaurus/core": "0.0.0-
|
|
29
|
-
"@docusaurus/logger": "0.0.0-
|
|
30
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
31
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
32
|
-
"@docusaurus/types": "0.0.0-
|
|
33
|
-
"@docusaurus/utils": "0.0.0-
|
|
34
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
37
|
+
"@docusaurus/core": "0.0.0-5123",
|
|
38
|
+
"@docusaurus/logger": "0.0.0-5123",
|
|
39
|
+
"@docusaurus/mdx-loader": "0.0.0-5123",
|
|
40
|
+
"@docusaurus/module-type-aliases": "0.0.0-5123",
|
|
41
|
+
"@docusaurus/types": "0.0.0-5123",
|
|
42
|
+
"@docusaurus/utils": "0.0.0-5123",
|
|
43
|
+
"@docusaurus/utils-validation": "0.0.0-5123",
|
|
35
44
|
"@types/react-router-config": "^5.0.6",
|
|
36
45
|
"combine-promises": "^1.1.0",
|
|
37
46
|
"fs-extra": "^10.1.0",
|
|
@@ -58,5 +67,5 @@
|
|
|
58
67
|
"engines": {
|
|
59
68
|
"node": ">=16.14"
|
|
60
69
|
},
|
|
61
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "c53a3e9c3a387b66c65d8eb28faa081274ff64e5"
|
|
62
71
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -18,15 +18,60 @@ import {
|
|
|
18
18
|
getActiveDocContext,
|
|
19
19
|
getDocVersionSuggestions,
|
|
20
20
|
} from './docsClientUtils';
|
|
21
|
-
import type {
|
|
22
|
-
GlobalPluginData,
|
|
23
|
-
GlobalVersion,
|
|
24
|
-
ActivePlugin,
|
|
25
|
-
ActiveDocContext,
|
|
26
|
-
DocVersionSuggestions,
|
|
27
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
28
21
|
import type {UseDataOptions} from '@docusaurus/types';
|
|
29
22
|
|
|
23
|
+
export type ActivePlugin = {
|
|
24
|
+
pluginId: string;
|
|
25
|
+
pluginData: GlobalPluginData;
|
|
26
|
+
};
|
|
27
|
+
export type ActiveDocContext = {
|
|
28
|
+
activeVersion?: GlobalVersion;
|
|
29
|
+
activeDoc?: GlobalDoc;
|
|
30
|
+
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
31
|
+
};
|
|
32
|
+
export type GlobalDoc = {
|
|
33
|
+
/**
|
|
34
|
+
* For generated index pages, this is the `slug`, **not** `permalink`
|
|
35
|
+
* (without base URL). Because slugs have leading slashes but IDs don't,
|
|
36
|
+
* there won't be clashes.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
path: string;
|
|
40
|
+
sidebar: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GlobalVersion = {
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
isLast: boolean;
|
|
47
|
+
path: string;
|
|
48
|
+
/** The doc with `slug: /`, or first doc in first sidebar */
|
|
49
|
+
mainDocId: string;
|
|
50
|
+
docs: GlobalDoc[];
|
|
51
|
+
/** Unversioned IDs. In development, this list is empty. */
|
|
52
|
+
draftIds: string[];
|
|
53
|
+
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type GlobalSidebar = {
|
|
57
|
+
link?: {
|
|
58
|
+
label: string;
|
|
59
|
+
path: string;
|
|
60
|
+
};
|
|
61
|
+
// ... we may add other things here later
|
|
62
|
+
};
|
|
63
|
+
export type GlobalPluginData = {
|
|
64
|
+
path: string;
|
|
65
|
+
versions: GlobalVersion[];
|
|
66
|
+
breadcrumbs: boolean;
|
|
67
|
+
};
|
|
68
|
+
export type DocVersionSuggestions = {
|
|
69
|
+
/** Suggest the latest version */
|
|
70
|
+
latestVersionSuggestion: GlobalVersion;
|
|
71
|
+
/** Suggest the same doc, in latest version (if one exists) */
|
|
72
|
+
latestDocSuggestion?: GlobalDoc;
|
|
73
|
+
};
|
|
74
|
+
|
|
30
75
|
// Important to use a constant object to avoid React useEffect executions etc.
|
|
31
76
|
// see https://github.com/facebook/docusaurus/issues/5089
|
|
32
77
|
const StableEmptyObject = {};
|
|
@@ -71,6 +116,7 @@ export function useActivePluginAndVersion(
|
|
|
71
116
|
};
|
|
72
117
|
}
|
|
73
118
|
|
|
119
|
+
/** Versions are returned ordered (most recent first). */
|
|
74
120
|
export function useVersions(pluginId: string | undefined): GlobalVersion[] {
|
|
75
121
|
const data = useDocsData(pluginId);
|
|
76
122
|
return data.versions;
|
|
@@ -81,6 +127,10 @@ export function useLatestVersion(pluginId: string | undefined): GlobalVersion {
|
|
|
81
127
|
return getLatestVersion(data);
|
|
82
128
|
}
|
|
83
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
132
|
+
* currently considered as active.
|
|
133
|
+
*/
|
|
84
134
|
export function useActiveVersion(
|
|
85
135
|
pluginId: string | undefined,
|
|
86
136
|
): GlobalVersion | undefined {
|
|
@@ -96,7 +146,9 @@ export function useActiveDocContext(
|
|
|
96
146
|
const {pathname} = useLocation();
|
|
97
147
|
return getActiveDocContext(data, pathname);
|
|
98
148
|
}
|
|
99
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
151
|
+
*/
|
|
100
152
|
export function useDocVersionSuggestions(
|
|
101
153
|
pluginId: string | undefined,
|
|
102
154
|
): DocVersionSuggestions {
|
|
@@ -616,89 +616,3 @@ declare module '@theme/DocPage' {
|
|
|
616
616
|
|
|
617
617
|
export default function DocPage(props: Props): JSX.Element;
|
|
618
618
|
}
|
|
619
|
-
|
|
620
|
-
// TODO TS only supports reading `exports` in 4.7. We will need to merge the
|
|
621
|
-
// type defs (and JSDoc) here with the implementation after that
|
|
622
|
-
declare module '@docusaurus/plugin-content-docs/client' {
|
|
623
|
-
import type {UseDataOptions} from '@docusaurus/types';
|
|
624
|
-
|
|
625
|
-
export type ActivePlugin = {
|
|
626
|
-
pluginId: string;
|
|
627
|
-
pluginData: GlobalPluginData;
|
|
628
|
-
};
|
|
629
|
-
export type ActiveDocContext = {
|
|
630
|
-
activeVersion?: GlobalVersion;
|
|
631
|
-
activeDoc?: GlobalDoc;
|
|
632
|
-
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
633
|
-
};
|
|
634
|
-
export type GlobalDoc = {
|
|
635
|
-
/**
|
|
636
|
-
* For generated index pages, this is the `slug`, **not** `permalink`
|
|
637
|
-
* (without base URL). Because slugs have leading slashes but IDs don't,
|
|
638
|
-
* there won't be clashes.
|
|
639
|
-
*/
|
|
640
|
-
id: string;
|
|
641
|
-
path: string;
|
|
642
|
-
sidebar: string | undefined;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
export type GlobalVersion = {
|
|
646
|
-
name: string;
|
|
647
|
-
label: string;
|
|
648
|
-
isLast: boolean;
|
|
649
|
-
path: string;
|
|
650
|
-
/** The doc with `slug: /`, or first doc in first sidebar */
|
|
651
|
-
mainDocId: string;
|
|
652
|
-
docs: GlobalDoc[];
|
|
653
|
-
/** Unversioned IDs. In development, this list is empty. */
|
|
654
|
-
draftIds: string[];
|
|
655
|
-
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
656
|
-
};
|
|
657
|
-
|
|
658
|
-
export type GlobalSidebar = {
|
|
659
|
-
link?: {
|
|
660
|
-
label: string;
|
|
661
|
-
path: string;
|
|
662
|
-
};
|
|
663
|
-
// ... we may add other things here later
|
|
664
|
-
};
|
|
665
|
-
export type GlobalPluginData = {
|
|
666
|
-
path: string;
|
|
667
|
-
versions: GlobalVersion[];
|
|
668
|
-
breadcrumbs: boolean;
|
|
669
|
-
};
|
|
670
|
-
export type DocVersionSuggestions = {
|
|
671
|
-
/** Suggest the latest version */
|
|
672
|
-
latestVersionSuggestion: GlobalVersion;
|
|
673
|
-
/** Suggest the same doc, in latest version (if one exists) */
|
|
674
|
-
latestDocSuggestion?: GlobalDoc;
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
|
|
678
|
-
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
679
|
-
export const useActivePlugin: (
|
|
680
|
-
options?: UseDataOptions,
|
|
681
|
-
) => ActivePlugin | undefined;
|
|
682
|
-
export const useActivePluginAndVersion: (
|
|
683
|
-
options?: UseDataOptions,
|
|
684
|
-
) =>
|
|
685
|
-
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
686
|
-
| undefined;
|
|
687
|
-
/** Versions are returned ordered (most recent first). */
|
|
688
|
-
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
689
|
-
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
690
|
-
/**
|
|
691
|
-
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
692
|
-
* currently considered as active.
|
|
693
|
-
*/
|
|
694
|
-
export const useActiveVersion: (
|
|
695
|
-
pluginId?: string,
|
|
696
|
-
) => GlobalVersion | undefined;
|
|
697
|
-
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
698
|
-
/**
|
|
699
|
-
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
700
|
-
*/
|
|
701
|
-
export const useDocVersionSuggestions: (
|
|
702
|
-
pluginId?: string,
|
|
703
|
-
) => DocVersionSuggestions;
|
|
704
|
-
}
|