@docusaurus/plugin-content-docs 0.0.0-4841 → 0.0.0-4842
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.
|
@@ -4,10 +4,11 @@
|
|
|
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,
|
|
7
|
+
import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
+
import type { UseDataOptions } from '@docusaurus/types';
|
|
8
9
|
export declare function getActivePlugin(allPluginData: {
|
|
9
10
|
[pluginId: string]: GlobalPluginData;
|
|
10
|
-
}, pathname: string, options?:
|
|
11
|
+
}, pathname: string, options?: UseDataOptions): ActivePlugin | undefined;
|
|
11
12
|
export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
|
|
12
13
|
export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => GlobalVersion | undefined;
|
|
13
14
|
export declare const getActiveDocContext: (data: GlobalPluginData, pathname: string) => ActiveDocContext;
|
package/lib/client/index.d.ts
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
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
|
|
7
|
+
import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
+
import type { UseDataOptions } from '@docusaurus/types';
|
|
8
9
|
export declare const useAllDocsData: () => {
|
|
9
10
|
[pluginId: string]: GlobalPluginData;
|
|
10
11
|
};
|
|
11
12
|
export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
|
|
12
|
-
export declare const useActivePlugin: (options?:
|
|
13
|
-
export declare const useActivePluginAndVersion: (options?:
|
|
13
|
+
export declare const useActivePlugin: (options?: UseDataOptions) => ActivePlugin | undefined;
|
|
14
|
+
export declare const useActivePluginAndVersion: (options?: UseDataOptions) => {
|
|
14
15
|
activePlugin: ActivePlugin;
|
|
15
16
|
activeVersion: GlobalVersion | undefined;
|
|
16
17
|
} | undefined;
|
package/lib/client/index.js
CHANGED
|
@@ -7,19 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActiveVersion = exports.useLatestVersion = exports.useVersions = exports.useActivePluginAndVersion = exports.useActivePlugin = exports.useDocsData = exports.useAllDocsData = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
10
|
const router_1 = require("@docusaurus/router");
|
|
12
|
-
const useGlobalData_1 =
|
|
11
|
+
const useGlobalData_1 = require("@docusaurus/useGlobalData");
|
|
13
12
|
const docsClientUtils_1 = require("./docsClientUtils");
|
|
14
13
|
// Important to use a constant object to avoid React useEffect executions etc.
|
|
15
14
|
// see https://github.com/facebook/docusaurus/issues/5089
|
|
16
15
|
const StableEmptyObject = {};
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// In blog-only mode, docs hooks are still used by the theme. We need a fail-
|
|
17
|
+
// safe fallback when the docs plugin is not in use
|
|
18
|
+
const useAllDocsData = () => (0, useGlobalData_1.useAllPluginInstancesData)('docusaurus-plugin-content-docs') ??
|
|
19
|
+
StableEmptyObject;
|
|
21
20
|
exports.useAllDocsData = useAllDocsData;
|
|
22
|
-
const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId
|
|
21
|
+
const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId, {
|
|
22
|
+
failfast: true,
|
|
23
|
+
});
|
|
23
24
|
exports.useDocsData = useDocsData;
|
|
24
25
|
// TODO this feature should be provided by docusaurus core
|
|
25
26
|
const useActivePlugin = (options = {}) => {
|
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-4842",
|
|
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-4842",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4842",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4842",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4842",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4842",
|
|
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.1"
|
|
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-4842",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4842",
|
|
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": "6bf15cea226810a6d8263f83eb2b6a56a5d0499b"
|
|
60
60
|
}
|
|
@@ -11,11 +11,11 @@ import type {
|
|
|
11
11
|
GlobalPluginData,
|
|
12
12
|
GlobalVersion,
|
|
13
13
|
GlobalDoc,
|
|
14
|
-
GetActivePluginOptions,
|
|
15
14
|
ActivePlugin,
|
|
16
15
|
ActiveDocContext,
|
|
17
16
|
DocVersionSuggestions,
|
|
18
17
|
} from '@docusaurus/plugin-content-docs/client';
|
|
18
|
+
import type {UseDataOptions} from '@docusaurus/types';
|
|
19
19
|
|
|
20
20
|
// This code is not part of the api surface, not in ./theme on purpose
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ import type {
|
|
|
25
25
|
export function getActivePlugin(
|
|
26
26
|
allPluginData: {[pluginId: string]: GlobalPluginData},
|
|
27
27
|
pathname: string,
|
|
28
|
-
options:
|
|
28
|
+
options: UseDataOptions = {},
|
|
29
29
|
): ActivePlugin | undefined {
|
|
30
30
|
const activeEntry = Object.entries(allPluginData)
|
|
31
31
|
// Route sorting: '/android/foo' should match '/android' instead of '/'
|
package/src/client/index.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {useLocation} from '@docusaurus/router';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
useAllPluginInstancesData,
|
|
11
|
+
usePluginData,
|
|
12
|
+
} from '@docusaurus/useGlobalData';
|
|
10
13
|
|
|
11
14
|
import {
|
|
12
15
|
getActivePlugin,
|
|
@@ -21,25 +24,27 @@ import type {
|
|
|
21
24
|
ActivePlugin,
|
|
22
25
|
ActiveDocContext,
|
|
23
26
|
DocVersionSuggestions,
|
|
24
|
-
GetActivePluginOptions,
|
|
25
27
|
} from '@docusaurus/plugin-content-docs/client';
|
|
28
|
+
import type {UseDataOptions} from '@docusaurus/types';
|
|
26
29
|
|
|
27
30
|
// Important to use a constant object to avoid React useEffect executions etc.
|
|
28
31
|
// see https://github.com/facebook/docusaurus/issues/5089
|
|
29
32
|
const StableEmptyObject = {};
|
|
30
33
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// plugin is not in use
|
|
34
|
+
// In blog-only mode, docs hooks are still used by the theme. We need a fail-
|
|
35
|
+
// safe fallback when the docs plugin is not in use
|
|
34
36
|
export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
|
|
35
|
-
|
|
37
|
+
useAllPluginInstancesData('docusaurus-plugin-content-docs') ??
|
|
38
|
+
StableEmptyObject;
|
|
36
39
|
|
|
37
40
|
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
|
38
|
-
usePluginData('docusaurus-plugin-content-docs', pluginId
|
|
41
|
+
usePluginData('docusaurus-plugin-content-docs', pluginId, {
|
|
42
|
+
failfast: true,
|
|
43
|
+
}) as GlobalPluginData;
|
|
39
44
|
|
|
40
45
|
// TODO this feature should be provided by docusaurus core
|
|
41
46
|
export const useActivePlugin = (
|
|
42
|
-
options:
|
|
47
|
+
options: UseDataOptions = {},
|
|
43
48
|
): ActivePlugin | undefined => {
|
|
44
49
|
const data = useAllDocsData();
|
|
45
50
|
const {pathname} = useLocation();
|
|
@@ -47,7 +52,7 @@ export const useActivePlugin = (
|
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
export const useActivePluginAndVersion = (
|
|
50
|
-
options:
|
|
55
|
+
options: UseDataOptions = {},
|
|
51
56
|
):
|
|
52
57
|
| undefined
|
|
53
58
|
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
|
|
@@ -612,6 +612,8 @@ declare module '@theme/DocPage/Layout/Main' {
|
|
|
612
612
|
|
|
613
613
|
// TODO until TS supports exports field... hope it's in 4.6
|
|
614
614
|
declare module '@docusaurus/plugin-content-docs/client' {
|
|
615
|
+
import type {UseDataOptions} from '@docusaurus/types';
|
|
616
|
+
|
|
615
617
|
export type ActivePlugin = {
|
|
616
618
|
pluginId: string;
|
|
617
619
|
pluginData: GlobalPluginData;
|
|
@@ -655,15 +657,14 @@ declare module '@docusaurus/plugin-content-docs/client' {
|
|
|
655
657
|
// suggest the same doc, in latest version (if exist)
|
|
656
658
|
latestDocSuggestion?: GlobalDoc;
|
|
657
659
|
};
|
|
658
|
-
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
|
|
659
660
|
|
|
660
661
|
export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
|
|
661
662
|
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
662
663
|
export const useActivePlugin: (
|
|
663
|
-
options?:
|
|
664
|
+
options?: UseDataOptions,
|
|
664
665
|
) => ActivePlugin | undefined;
|
|
665
666
|
export const useActivePluginAndVersion: (
|
|
666
|
-
options?:
|
|
667
|
+
options?: UseDataOptions,
|
|
667
668
|
) =>
|
|
668
669
|
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
669
670
|
| undefined;
|