@docusaurus/plugin-content-docs 0.0.0-4550 → 0.0.0-4554

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,4 +4,16 @@
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
- export * from './globalDataHooks';
7
+ import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
8
+ export declare const useAllDocsData: () => Record<string, GlobalPluginData>;
9
+ export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
10
+ export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
11
+ export declare const useActivePluginAndVersion: (options?: GetActivePluginOptions) => {
12
+ activePlugin: ActivePlugin;
13
+ activeVersion: GlobalVersion | undefined;
14
+ } | undefined;
15
+ export declare const useVersions: (pluginId: string | undefined) => GlobalVersion[];
16
+ export declare const useLatestVersion: (pluginId: string | undefined) => GlobalVersion;
17
+ export declare const useActiveVersion: (pluginId: string | undefined) => GlobalVersion | undefined;
18
+ export declare const useActiveDocContext: (pluginId: string | undefined) => ActiveDocContext;
19
+ export declare const useDocVersionSuggestions: (pluginId: string | undefined) => DocVersionSuggestions;
@@ -6,5 +6,70 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActiveVersion = exports.useLatestVersion = exports.useVersions = exports.useActivePluginAndVersion = exports.useActivePlugin = exports.useDocsData = exports.useAllDocsData = void 0;
9
10
  const tslib_1 = require("tslib");
10
- (0, tslib_1.__exportStar)(require("./globalDataHooks"), exports);
11
+ const router_1 = require("@docusaurus/router");
12
+ const useGlobalData_1 = (0, tslib_1.__importStar)(require("@docusaurus/useGlobalData"));
13
+ const docsClientUtils_1 = require("./docsClientUtils");
14
+ // Important to use a constant object to avoid React useEffect executions etc.
15
+ // see https://github.com/facebook/docusaurus/issues/5089
16
+ const StableEmptyObject = {};
17
+ // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
18
+ // are still used by the theme. We need a fail-safe fallback when the docs
19
+ // plugin is not in use
20
+ const useAllDocsData = () => { var _a; return (_a = (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs']) !== null && _a !== void 0 ? _a : StableEmptyObject; };
21
+ exports.useAllDocsData = useAllDocsData;
22
+ const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
23
+ exports.useDocsData = useDocsData;
24
+ // TODO this feature should be provided by docusaurus core
25
+ const useActivePlugin = (options = {}) => {
26
+ const data = (0, exports.useAllDocsData)();
27
+ const { pathname } = (0, router_1.useLocation)();
28
+ return (0, docsClientUtils_1.getActivePlugin)(data, pathname, options);
29
+ };
30
+ exports.useActivePlugin = useActivePlugin;
31
+ const useActivePluginAndVersion = (options = {}) => {
32
+ const activePlugin = (0, exports.useActivePlugin)(options);
33
+ const { pathname } = (0, router_1.useLocation)();
34
+ if (activePlugin) {
35
+ const activeVersion = (0, docsClientUtils_1.getActiveVersion)(activePlugin.pluginData, pathname);
36
+ return {
37
+ activePlugin,
38
+ activeVersion,
39
+ };
40
+ }
41
+ return undefined;
42
+ };
43
+ exports.useActivePluginAndVersion = useActivePluginAndVersion;
44
+ // versions are returned ordered (most recent first)
45
+ const useVersions = (pluginId) => {
46
+ const data = (0, exports.useDocsData)(pluginId);
47
+ return data.versions;
48
+ };
49
+ exports.useVersions = useVersions;
50
+ const useLatestVersion = (pluginId) => {
51
+ const data = (0, exports.useDocsData)(pluginId);
52
+ return (0, docsClientUtils_1.getLatestVersion)(data);
53
+ };
54
+ exports.useLatestVersion = useLatestVersion;
55
+ // Note: return undefined on doc-unrelated pages,
56
+ // because there's no version currently considered as active
57
+ const useActiveVersion = (pluginId) => {
58
+ const data = (0, exports.useDocsData)(pluginId);
59
+ const { pathname } = (0, router_1.useLocation)();
60
+ return (0, docsClientUtils_1.getActiveVersion)(data, pathname);
61
+ };
62
+ exports.useActiveVersion = useActiveVersion;
63
+ const useActiveDocContext = (pluginId) => {
64
+ const data = (0, exports.useDocsData)(pluginId);
65
+ const { pathname } = (0, router_1.useLocation)();
66
+ return (0, docsClientUtils_1.getActiveDocContext)(data, pathname);
67
+ };
68
+ exports.useActiveDocContext = useActiveDocContext;
69
+ // Useful to say "hey, you are not on the latest docs version, please switch"
70
+ const useDocVersionSuggestions = (pluginId) => {
71
+ const data = (0, exports.useDocsData)(pluginId);
72
+ const { pathname } = (0, router_1.useLocation)();
73
+ return (0, docsClientUtils_1.getDocVersionSuggestions)(data, pathname);
74
+ };
75
+ exports.useDocVersionSuggestions = useDocVersionSuggestions;
@@ -4,5 +4,5 @@
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
- export * from '../constants';
8
- export { filterVersions, getDefaultVersionBanner, getVersionBadge, getVersionBanner, getVersionsFilePath, readVersionsFile, readVersionNames, } from '../versions';
7
+ export { CURRENT_VERSION_NAME, VERSIONED_DOCS_DIR, VERSIONED_SIDEBARS_DIR, VERSIONS_JSON_FILE, } from './constants';
8
+ export { filterVersions, getDefaultVersionBanner, getVersionBadge, getVersionBanner, getVersionsFilePath, readVersionsFile, readVersionNames, } from './versions';
@@ -6,11 +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.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionBanner = exports.getVersionBadge = exports.getDefaultVersionBanner = exports.filterVersions = void 0;
10
- const tslib_1 = require("tslib");
9
+ exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionBanner = exports.getVersionBadge = exports.getDefaultVersionBanner = exports.filterVersions = exports.VERSIONS_JSON_FILE = exports.VERSIONED_SIDEBARS_DIR = exports.VERSIONED_DOCS_DIR = exports.CURRENT_VERSION_NAME = void 0;
11
10
  // APIs available to Node.js
12
- (0, tslib_1.__exportStar)(require("../constants"), exports);
13
- var versions_1 = require("../versions");
11
+ var constants_1 = require("./constants");
12
+ Object.defineProperty(exports, "CURRENT_VERSION_NAME", { enumerable: true, get: function () { return constants_1.CURRENT_VERSION_NAME; } });
13
+ Object.defineProperty(exports, "VERSIONED_DOCS_DIR", { enumerable: true, get: function () { return constants_1.VERSIONED_DOCS_DIR; } });
14
+ Object.defineProperty(exports, "VERSIONED_SIDEBARS_DIR", { enumerable: true, get: function () { return constants_1.VERSIONED_SIDEBARS_DIR; } });
15
+ Object.defineProperty(exports, "VERSIONS_JSON_FILE", { enumerable: true, get: function () { return constants_1.VERSIONS_JSON_FILE; } });
16
+ var versions_1 = require("./versions");
14
17
  Object.defineProperty(exports, "filterVersions", { enumerable: true, get: function () { return versions_1.filterVersions; } });
15
18
  Object.defineProperty(exports, "getDefaultVersionBanner", { enumerable: true, get: function () { return versions_1.getDefaultVersionBanner; } });
16
19
  Object.defineProperty(exports, "getVersionBadge", { enumerable: true, get: function () { return versions_1.getVersionBadge; } });
@@ -184,7 +184,6 @@ Available document ids are:
184
184
  }
185
185
  function getFirstLink(sidebar) {
186
186
  var _a, _b, _c;
187
- // eslint-disable-next-line no-restricted-syntax
188
187
  for (const item of sidebar) {
189
188
  if (item.type === 'doc') {
190
189
  return {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4550",
3
+ "version": "0.0.0-4554",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
7
7
  "./client": "./lib/client/index.js",
8
- "./server": "./lib/server/index.js",
8
+ "./server": "./lib/server-export.js",
9
9
  ".": "./lib/index.js"
10
10
  },
11
11
  "types": "src/plugin-content-docs.d.ts",
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4550",
27
- "@docusaurus/logger": "0.0.0-4550",
28
- "@docusaurus/mdx-loader": "0.0.0-4550",
29
- "@docusaurus/utils": "0.0.0-4550",
30
- "@docusaurus/utils-validation": "0.0.0-4550",
26
+ "@docusaurus/core": "0.0.0-4554",
27
+ "@docusaurus/logger": "0.0.0-4554",
28
+ "@docusaurus/mdx-loader": "0.0.0-4554",
29
+ "@docusaurus/utils": "0.0.0-4554",
30
+ "@docusaurus/utils-validation": "0.0.0-4554",
31
31
  "combine-promises": "^1.1.0",
32
32
  "fs-extra": "^10.0.0",
33
33
  "import-fresh": "^3.2.2",
@@ -40,8 +40,8 @@
40
40
  "webpack": "^5.68.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@docusaurus/module-type-aliases": "0.0.0-4550",
44
- "@docusaurus/types": "0.0.0-4550",
43
+ "@docusaurus/module-type-aliases": "0.0.0-4554",
44
+ "@docusaurus/types": "0.0.0-4554",
45
45
  "@types/js-yaml": "^4.0.0",
46
46
  "@types/picomatch": "^2.2.1",
47
47
  "commander": "^5.1.0",
@@ -57,5 +57,5 @@
57
57
  "engines": {
58
58
  "node": ">=14"
59
59
  },
60
- "gitHead": "9eccadbbf68a877760b1ee7a42484df09cd9d862"
60
+ "gitHead": "d599cd10202242196737527108e8a15beef1443d"
61
61
  }
@@ -5,4 +5,100 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- export * from './globalDataHooks';
8
+ import {useLocation} from '@docusaurus/router';
9
+ import useGlobalData, {usePluginData} from '@docusaurus/useGlobalData';
10
+
11
+ import {
12
+ getActivePlugin,
13
+ getLatestVersion,
14
+ getActiveVersion,
15
+ getActiveDocContext,
16
+ getDocVersionSuggestions,
17
+ } from './docsClientUtils';
18
+ import type {
19
+ GlobalPluginData,
20
+ GlobalVersion,
21
+ ActivePlugin,
22
+ ActiveDocContext,
23
+ DocVersionSuggestions,
24
+ GetActivePluginOptions,
25
+ } from '@docusaurus/plugin-content-docs/client';
26
+
27
+ // Important to use a constant object to avoid React useEffect executions etc.
28
+ // see https://github.com/facebook/docusaurus/issues/5089
29
+ const StableEmptyObject = {};
30
+
31
+ // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
32
+ // are still used by the theme. We need a fail-safe fallback when the docs
33
+ // plugin is not in use
34
+ export const useAllDocsData = (): Record<string, GlobalPluginData> =>
35
+ useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
36
+
37
+ export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
38
+ usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
39
+
40
+ // TODO this feature should be provided by docusaurus core
41
+ export const useActivePlugin = (
42
+ options: GetActivePluginOptions = {},
43
+ ): ActivePlugin | undefined => {
44
+ const data = useAllDocsData();
45
+ const {pathname} = useLocation();
46
+ return getActivePlugin(data, pathname, options);
47
+ };
48
+
49
+ export const useActivePluginAndVersion = (
50
+ options: GetActivePluginOptions = {},
51
+ ):
52
+ | undefined
53
+ | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
54
+ const activePlugin = useActivePlugin(options);
55
+ const {pathname} = useLocation();
56
+ if (activePlugin) {
57
+ const activeVersion = getActiveVersion(activePlugin.pluginData, pathname);
58
+ return {
59
+ activePlugin,
60
+ activeVersion,
61
+ };
62
+ }
63
+ return undefined;
64
+ };
65
+
66
+ // versions are returned ordered (most recent first)
67
+ export const useVersions = (pluginId: string | undefined): GlobalVersion[] => {
68
+ const data = useDocsData(pluginId);
69
+ return data.versions;
70
+ };
71
+
72
+ export const useLatestVersion = (
73
+ pluginId: string | undefined,
74
+ ): GlobalVersion => {
75
+ const data = useDocsData(pluginId);
76
+ return getLatestVersion(data);
77
+ };
78
+
79
+ // Note: return undefined on doc-unrelated pages,
80
+ // because there's no version currently considered as active
81
+ export const useActiveVersion = (
82
+ pluginId: string | undefined,
83
+ ): GlobalVersion | undefined => {
84
+ const data = useDocsData(pluginId);
85
+ const {pathname} = useLocation();
86
+ return getActiveVersion(data, pathname);
87
+ };
88
+
89
+ export const useActiveDocContext = (
90
+ pluginId: string | undefined,
91
+ ): ActiveDocContext => {
92
+ const data = useDocsData(pluginId);
93
+ const {pathname} = useLocation();
94
+ return getActiveDocContext(data, pathname);
95
+ };
96
+
97
+ // Useful to say "hey, you are not on the latest docs version, please switch"
98
+ export const useDocVersionSuggestions = (
99
+ pluginId: string | undefined,
100
+ ): DocVersionSuggestions => {
101
+ const data = useDocsData(pluginId);
102
+ const {pathname} = useLocation();
103
+ return getDocVersionSuggestions(data, pathname);
104
+ };
@@ -6,7 +6,12 @@
6
6
  */
7
7
 
8
8
  // APIs available to Node.js
9
- export * from '../constants';
9
+ export {
10
+ CURRENT_VERSION_NAME,
11
+ VERSIONED_DOCS_DIR,
12
+ VERSIONED_SIDEBARS_DIR,
13
+ VERSIONS_JSON_FILE,
14
+ } from './constants';
10
15
 
11
16
  export {
12
17
  filterVersions,
@@ -16,4 +21,4 @@ export {
16
21
  getVersionsFilePath,
17
22
  readVersionsFile,
18
23
  readVersionNames,
19
- } from '../versions';
24
+ } from './versions';
@@ -303,7 +303,6 @@ Available document ids are:
303
303
  label: string;
304
304
  }
305
305
  | undefined {
306
- // eslint-disable-next-line no-restricted-syntax
307
306
  for (const item of sidebar) {
308
307
  if (item.type === 'doc') {
309
308
  return {
@@ -1,19 +0,0 @@
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
- import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
8
- export declare const useAllDocsData: () => Record<string, GlobalPluginData>;
9
- export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
10
- export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
11
- export declare const useActivePluginAndVersion: (options?: GetActivePluginOptions) => {
12
- activePlugin: ActivePlugin;
13
- activeVersion: GlobalVersion | undefined;
14
- } | undefined;
15
- export declare const useVersions: (pluginId: string | undefined) => GlobalVersion[];
16
- export declare const useLatestVersion: (pluginId: string | undefined) => GlobalVersion;
17
- export declare const useActiveVersion: (pluginId: string | undefined) => GlobalVersion | undefined;
18
- export declare const useActiveDocContext: (pluginId: string | undefined) => ActiveDocContext;
19
- export declare const useDocVersionSuggestions: (pluginId: string | undefined) => DocVersionSuggestions;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Facebook, Inc. and its affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
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
- const router_1 = require("@docusaurus/router");
12
- const useGlobalData_1 = (0, tslib_1.__importStar)(require("@docusaurus/useGlobalData"));
13
- const docsClientUtils_1 = require("./docsClientUtils");
14
- // Important to use a constant object to avoid React useEffect executions etc.
15
- // see https://github.com/facebook/docusaurus/issues/5089
16
- const StableEmptyObject = {};
17
- // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
18
- // are still used by the theme. We need a fail-safe fallback when the docs
19
- // plugin is not in use
20
- const useAllDocsData = () => { var _a;
21
- // useAllPluginInstancesData('docusaurus-plugin-content-docs');
22
- return (_a = (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs']) !== null && _a !== void 0 ? _a : StableEmptyObject; };
23
- exports.useAllDocsData = useAllDocsData;
24
- const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
25
- exports.useDocsData = useDocsData;
26
- // TODO this feature should be provided by docusaurus core
27
- const useActivePlugin = (options = {}) => {
28
- const data = (0, exports.useAllDocsData)();
29
- const { pathname } = (0, router_1.useLocation)();
30
- return (0, docsClientUtils_1.getActivePlugin)(data, pathname, options);
31
- };
32
- exports.useActivePlugin = useActivePlugin;
33
- const useActivePluginAndVersion = (options = {}) => {
34
- const activePlugin = (0, exports.useActivePlugin)(options);
35
- const { pathname } = (0, router_1.useLocation)();
36
- if (activePlugin) {
37
- const activeVersion = (0, docsClientUtils_1.getActiveVersion)(activePlugin.pluginData, pathname);
38
- return {
39
- activePlugin,
40
- activeVersion,
41
- };
42
- }
43
- return undefined;
44
- };
45
- exports.useActivePluginAndVersion = useActivePluginAndVersion;
46
- // versions are returned ordered (most recent first)
47
- const useVersions = (pluginId) => {
48
- const data = (0, exports.useDocsData)(pluginId);
49
- return data.versions;
50
- };
51
- exports.useVersions = useVersions;
52
- const useLatestVersion = (pluginId) => {
53
- const data = (0, exports.useDocsData)(pluginId);
54
- return (0, docsClientUtils_1.getLatestVersion)(data);
55
- };
56
- exports.useLatestVersion = useLatestVersion;
57
- // Note: return undefined on doc-unrelated pages,
58
- // because there's no version currently considered as active
59
- const useActiveVersion = (pluginId) => {
60
- const data = (0, exports.useDocsData)(pluginId);
61
- const { pathname } = (0, router_1.useLocation)();
62
- return (0, docsClientUtils_1.getActiveVersion)(data, pathname);
63
- };
64
- exports.useActiveVersion = useActiveVersion;
65
- const useActiveDocContext = (pluginId) => {
66
- const data = (0, exports.useDocsData)(pluginId);
67
- const { pathname } = (0, router_1.useLocation)();
68
- return (0, docsClientUtils_1.getActiveDocContext)(data, pathname);
69
- };
70
- exports.useActiveDocContext = useActiveDocContext;
71
- // Useful to say "hey, you are not on the latest docs version, please switch"
72
- const useDocVersionSuggestions = (pluginId) => {
73
- const data = (0, exports.useDocsData)(pluginId);
74
- const { pathname } = (0, router_1.useLocation)();
75
- return (0, docsClientUtils_1.getDocVersionSuggestions)(data, pathname);
76
- };
77
- exports.useDocVersionSuggestions = useDocVersionSuggestions;
@@ -1,108 +0,0 @@
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 {useLocation} from '@docusaurus/router';
9
- import useGlobalData, {
10
- // useAllPluginInstancesData,
11
- usePluginData,
12
- } from '@docusaurus/useGlobalData';
13
-
14
- import {
15
- getActivePlugin,
16
- getLatestVersion,
17
- getActiveVersion,
18
- getActiveDocContext,
19
- getDocVersionSuggestions,
20
- } from './docsClientUtils';
21
- import type {
22
- GlobalPluginData,
23
- GlobalVersion,
24
- ActivePlugin,
25
- ActiveDocContext,
26
- DocVersionSuggestions,
27
- GetActivePluginOptions,
28
- } from '@docusaurus/plugin-content-docs/client';
29
-
30
- // Important to use a constant object to avoid React useEffect executions etc.
31
- // see https://github.com/facebook/docusaurus/issues/5089
32
- const StableEmptyObject = {};
33
-
34
- // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
35
- // are still used by the theme. We need a fail-safe fallback when the docs
36
- // plugin is not in use
37
- export const useAllDocsData = (): Record<string, GlobalPluginData> =>
38
- // useAllPluginInstancesData('docusaurus-plugin-content-docs');
39
- useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
40
-
41
- export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
42
- usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
43
-
44
- // TODO this feature should be provided by docusaurus core
45
- export const useActivePlugin = (
46
- options: GetActivePluginOptions = {},
47
- ): ActivePlugin | undefined => {
48
- const data = useAllDocsData();
49
- const {pathname} = useLocation();
50
- return getActivePlugin(data, pathname, options);
51
- };
52
-
53
- export const useActivePluginAndVersion = (
54
- options: GetActivePluginOptions = {},
55
- ):
56
- | undefined
57
- | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
58
- const activePlugin = useActivePlugin(options);
59
- const {pathname} = useLocation();
60
- if (activePlugin) {
61
- const activeVersion = getActiveVersion(activePlugin.pluginData, pathname);
62
- return {
63
- activePlugin,
64
- activeVersion,
65
- };
66
- }
67
- return undefined;
68
- };
69
-
70
- // versions are returned ordered (most recent first)
71
- export const useVersions = (pluginId: string | undefined): GlobalVersion[] => {
72
- const data = useDocsData(pluginId);
73
- return data.versions;
74
- };
75
-
76
- export const useLatestVersion = (
77
- pluginId: string | undefined,
78
- ): GlobalVersion => {
79
- const data = useDocsData(pluginId);
80
- return getLatestVersion(data);
81
- };
82
-
83
- // Note: return undefined on doc-unrelated pages,
84
- // because there's no version currently considered as active
85
- export const useActiveVersion = (
86
- pluginId: string | undefined,
87
- ): GlobalVersion | undefined => {
88
- const data = useDocsData(pluginId);
89
- const {pathname} = useLocation();
90
- return getActiveVersion(data, pathname);
91
- };
92
-
93
- export const useActiveDocContext = (
94
- pluginId: string | undefined,
95
- ): ActiveDocContext => {
96
- const data = useDocsData(pluginId);
97
- const {pathname} = useLocation();
98
- return getActiveDocContext(data, pathname);
99
- };
100
-
101
- // Useful to say "hey, you are not on the latest docs version, please switch"
102
- export const useDocVersionSuggestions = (
103
- pluginId: string | undefined,
104
- ): DocVersionSuggestions => {
105
- const data = useDocsData(pluginId);
106
- const {pathname} = useLocation();
107
- return getDocVersionSuggestions(data, pathname);
108
- };