@docusaurus/plugin-content-docs 0.0.0-4839 → 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.
package/lib/cli.d.ts CHANGED
@@ -4,5 +4,6 @@
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 { PathOptions, SidebarOptions } from '@docusaurus/plugin-content-docs';
8
- export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): Promise<void>;
7
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
+ import type { LoadContext } from '@docusaurus/types';
9
+ export declare function cliDocsVersionCommand(version: string | null | undefined, { id: pluginId, path: docsPath, sidebarPath }: PluginOptions, { siteDir, i18n }: LoadContext): Promise<void>;
package/lib/cli.js CHANGED
@@ -12,6 +12,7 @@ const versions_1 = require("./versions");
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
13
  const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const sidebars_1 = require("./sidebars");
15
+ const constants_1 = require("./constants");
15
16
  const utils_1 = require("@docusaurus/utils");
16
17
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
17
18
  async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
@@ -30,7 +31,7 @@ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, vers
30
31
  }
31
32
  }
32
33
  // Tests depend on non-default export for mocking.
33
- async function cliDocsVersionCommand(version, siteDir, pluginId, options) {
34
+ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, sidebarPath }, { siteDir, i18n }) {
34
35
  // It wouldn't be very user-friendly to show a [default] log prefix,
35
36
  // so we use [docs] instead of [default]
36
37
  const pluginIdLogPrefix = pluginId === utils_1.DEFAULT_PLUGIN_ID ? '[docs]' : `[${pluginId}]`;
@@ -62,18 +63,39 @@ async function cliDocsVersionCommand(version, siteDir, pluginId, options) {
62
63
  if (versions.includes(version)) {
63
64
  throw new Error(`${pluginIdLogPrefix}: this version already exists! Use a version tag that does not already exist.`);
64
65
  }
65
- const { path: docsPath, sidebarPath } = options;
66
- // Copy docs files.
67
- const docsDir = path_1.default.resolve(siteDir, docsPath);
68
- if ((await fs_extra_1.default.pathExists(docsDir)) &&
69
- (await fs_extra_1.default.readdir(docsDir)).length > 0) {
70
- const versionedDir = (0, versions_1.getVersionedDocsDirPath)(siteDir, pluginId);
71
- const newVersionDir = path_1.default.join(versionedDir, `version-${version}`);
72
- await fs_extra_1.default.copy(docsDir, newVersionDir);
73
- }
74
- else {
75
- throw new Error(`${pluginIdLogPrefix}: no docs found in ${docsDir}.`);
66
+ if (i18n.locales.length > 1) {
67
+ logger_1.default.info `Versioned docs will be created for the following locales: name=${i18n.locales}`;
76
68
  }
69
+ await Promise.all(i18n.locales.map(async (locale) => {
70
+ // Copy docs files.
71
+ const docsDir = locale === i18n.defaultLocale
72
+ ? path_1.default.resolve(siteDir, docsPath)
73
+ : (0, versions_1.getDocsDirPathLocalized)({
74
+ siteDir,
75
+ locale,
76
+ pluginId,
77
+ versionName: constants_1.CURRENT_VERSION_NAME,
78
+ });
79
+ if (!(await fs_extra_1.default.pathExists(docsDir)) ||
80
+ (await fs_extra_1.default.readdir(docsDir)).length === 0) {
81
+ if (locale === i18n.defaultLocale) {
82
+ throw new Error(logger_1.default.interpolate `${pluginIdLogPrefix}: no docs found in path=${docsDir}.`);
83
+ }
84
+ else {
85
+ logger_1.default.warn `${pluginIdLogPrefix}: no docs found in path=${docsDir}. Skipping.`;
86
+ return;
87
+ }
88
+ }
89
+ const newVersionDir = locale === i18n.defaultLocale
90
+ ? path_1.default.join((0, versions_1.getVersionedDocsDirPath)(siteDir, pluginId), `version-${version}`)
91
+ : (0, versions_1.getDocsDirPathLocalized)({
92
+ siteDir,
93
+ locale,
94
+ pluginId,
95
+ versionName: version,
96
+ });
97
+ await fs_extra_1.default.copy(docsDir, newVersionDir);
98
+ }));
77
99
  await createVersionedSidebarFile({
78
100
  siteDir,
79
101
  pluginId,
@@ -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, GetActivePluginOptions, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
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?: GetActivePluginOptions): ActivePlugin | undefined;
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;
@@ -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, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
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?: GetActivePluginOptions) => ActivePlugin | undefined;
13
- export declare const useActivePluginAndVersion: (options?: GetActivePluginOptions) => {
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;
@@ -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 = tslib_1.__importStar(require("@docusaurus/useGlobalData"));
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
- // 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 = () => (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
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/lib/index.js CHANGED
@@ -27,7 +27,7 @@ const categoryGeneratedIndex_1 = require("./categoryGeneratedIndex");
27
27
  async function pluginContentDocs(context, options) {
28
28
  const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
29
29
  const versionsMetadata = await (0, versions_1.readVersionsMetadata)({ context, options });
30
- const pluginId = options.id ?? utils_1.DEFAULT_PLUGIN_ID;
30
+ const pluginId = options.id;
31
31
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
32
32
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
33
33
  const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
@@ -48,12 +48,7 @@ async function pluginContentDocs(context, options) {
48
48
  .arguments('<version>')
49
49
  .description(commandDescription)
50
50
  .action((version) => {
51
- (0, cli_1.cliDocsVersionCommand)(version, siteDir, pluginId, {
52
- path: options.path,
53
- sidebarPath: options.sidebarPath,
54
- sidebarCollapsed: options.sidebarCollapsed,
55
- sidebarCollapsible: options.sidebarCollapsible,
56
- });
51
+ (0, cli_1.cliDocsVersionCommand)(version, options, context);
57
52
  });
58
53
  },
59
54
  getTranslationFiles({ content }) {
package/lib/versions.d.ts CHANGED
@@ -11,6 +11,12 @@ export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: s
11
11
  export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
12
12
  export declare function readVersionsFile(siteDir: string, pluginId: string): Promise<string[] | null>;
13
13
  export declare function readVersionNames(siteDir: string, options: Pick<PluginOptions, 'id' | 'disableVersioning' | 'includeCurrentVersion'>): Promise<string[]>;
14
+ export declare function getDocsDirPathLocalized({ siteDir, locale, pluginId, versionName, }: {
15
+ siteDir: string;
16
+ locale: string;
17
+ pluginId: string;
18
+ versionName: string;
19
+ }): string;
14
20
  export declare function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }: {
15
21
  versionName: string;
16
22
  versionNames: string[];
package/lib/versions.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.readVersionsMetadata = exports.filterVersions = exports.getVersionBadge = exports.getVersionBanner = exports.getDefaultVersionBanner = exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
9
+ exports.readVersionsMetadata = exports.filterVersions = exports.getVersionBadge = exports.getVersionBanner = exports.getDefaultVersionBanner = exports.getDocsDirPathLocalized = exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
@@ -89,6 +89,7 @@ function getDocsDirPathLocalized({ siteDir, locale, pluginId, versionName, }) {
89
89
  ],
90
90
  });
91
91
  }
92
+ exports.getDocsDirPathLocalized = getDocsDirPathLocalized;
92
93
  function getVersionMetadataPaths({ versionName, context, options, }) {
93
94
  const isCurrentVersion = versionName === constants_1.CURRENT_VERSION_NAME;
94
95
  const contentPathLocalized = getDocsDirPathLocalized({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4839",
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-4839",
27
- "@docusaurus/logger": "0.0.0-4839",
28
- "@docusaurus/mdx-loader": "0.0.0-4839",
29
- "@docusaurus/utils": "0.0.0-4839",
30
- "@docusaurus/utils-validation": "0.0.0-4839",
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-4839",
43
- "@docusaurus/types": "0.0.0-4839",
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": "9e77b44561516ba299e3f93d4e6d0c47c687494d"
59
+ "gitHead": "6bf15cea226810a6d8263f83eb2b6a56a5d0499b"
60
60
  }
package/src/cli.ts CHANGED
@@ -9,16 +9,16 @@ import {
9
9
  getVersionsFilePath,
10
10
  getVersionedDocsDirPath,
11
11
  getVersionedSidebarsDirPath,
12
+ getDocsDirPathLocalized,
12
13
  } from './versions';
13
14
  import fs from 'fs-extra';
14
15
  import path from 'path';
15
- import type {
16
- PathOptions,
17
- SidebarOptions,
18
- } from '@docusaurus/plugin-content-docs';
16
+ import type {PluginOptions} from '@docusaurus/plugin-content-docs';
19
17
  import {loadSidebarsFileUnsafe, resolveSidebarPathOption} from './sidebars';
18
+ import {CURRENT_VERSION_NAME} from './constants';
20
19
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
21
20
  import logger from '@docusaurus/logger';
21
+ import type {LoadContext} from '@docusaurus/types';
22
22
 
23
23
  async function createVersionedSidebarFile({
24
24
  siteDir,
@@ -58,9 +58,8 @@ async function createVersionedSidebarFile({
58
58
  // Tests depend on non-default export for mocking.
59
59
  export async function cliDocsVersionCommand(
60
60
  version: string | null | undefined,
61
- siteDir: string,
62
- pluginId: string,
63
- options: PathOptions & SidebarOptions,
61
+ {id: pluginId, path: docsPath, sidebarPath}: PluginOptions,
62
+ {siteDir, i18n}: LoadContext,
64
63
  ): Promise<void> {
65
64
  // It wouldn't be very user-friendly to show a [default] log prefix,
66
65
  // so we use [docs] instead of [default]
@@ -114,22 +113,53 @@ export async function cliDocsVersionCommand(
114
113
  );
115
114
  }
116
115
 
117
- const {path: docsPath, sidebarPath} = options;
118
-
119
- // Copy docs files.
120
- const docsDir = path.resolve(siteDir, docsPath);
121
-
122
- if (
123
- (await fs.pathExists(docsDir)) &&
124
- (await fs.readdir(docsDir)).length > 0
125
- ) {
126
- const versionedDir = getVersionedDocsDirPath(siteDir, pluginId);
127
- const newVersionDir = path.join(versionedDir, `version-${version}`);
128
- await fs.copy(docsDir, newVersionDir);
129
- } else {
130
- throw new Error(`${pluginIdLogPrefix}: no docs found in ${docsDir}.`);
116
+ if (i18n.locales.length > 1) {
117
+ logger.info`Versioned docs will be created for the following locales: name=${i18n.locales}`;
131
118
  }
132
119
 
120
+ await Promise.all(
121
+ i18n.locales.map(async (locale) => {
122
+ // Copy docs files.
123
+ const docsDir =
124
+ locale === i18n.defaultLocale
125
+ ? path.resolve(siteDir, docsPath)
126
+ : getDocsDirPathLocalized({
127
+ siteDir,
128
+ locale,
129
+ pluginId,
130
+ versionName: CURRENT_VERSION_NAME,
131
+ });
132
+
133
+ if (
134
+ !(await fs.pathExists(docsDir)) ||
135
+ (await fs.readdir(docsDir)).length === 0
136
+ ) {
137
+ if (locale === i18n.defaultLocale) {
138
+ throw new Error(
139
+ logger.interpolate`${pluginIdLogPrefix}: no docs found in path=${docsDir}.`,
140
+ );
141
+ } else {
142
+ logger.warn`${pluginIdLogPrefix}: no docs found in path=${docsDir}. Skipping.`;
143
+ return;
144
+ }
145
+ }
146
+
147
+ const newVersionDir =
148
+ locale === i18n.defaultLocale
149
+ ? path.join(
150
+ getVersionedDocsDirPath(siteDir, pluginId),
151
+ `version-${version}`,
152
+ )
153
+ : getDocsDirPathLocalized({
154
+ siteDir,
155
+ locale,
156
+ pluginId,
157
+ versionName: version,
158
+ });
159
+ await fs.copy(docsDir, newVersionDir);
160
+ }),
161
+ );
162
+
133
163
  await createVersionedSidebarFile({
134
164
  siteDir,
135
165
  pluginId,
@@ -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: GetActivePluginOptions = {},
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 '/'
@@ -6,7 +6,10 @@
6
6
  */
7
7
 
8
8
  import {useLocation} from '@docusaurus/router';
9
- import useGlobalData, {usePluginData} from '@docusaurus/useGlobalData';
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
- // 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
+ // 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
- useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
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) as GlobalPluginData;
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: GetActivePluginOptions = {},
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: GetActivePluginOptions = {},
55
+ options: UseDataOptions = {},
51
56
  ):
52
57
  | undefined
53
58
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
package/src/index.ts CHANGED
@@ -67,7 +67,7 @@ export default async function pluginContentDocs(
67
67
 
68
68
  const versionsMetadata = await readVersionsMetadata({context, options});
69
69
 
70
- const pluginId = options.id ?? DEFAULT_PLUGIN_ID;
70
+ const pluginId = options.id;
71
71
 
72
72
  const pluginDataDirRoot = path.join(
73
73
  generatedFilesDir,
@@ -97,12 +97,7 @@ export default async function pluginContentDocs(
97
97
  .arguments('<version>')
98
98
  .description(commandDescription)
99
99
  .action((version) => {
100
- cliDocsVersionCommand(version, siteDir, pluginId, {
101
- path: options.path,
102
- sidebarPath: options.sidebarPath,
103
- sidebarCollapsed: options.sidebarCollapsed,
104
- sidebarCollapsible: options.sidebarCollapsible,
105
- });
100
+ cliDocsVersionCommand(version, options, context);
106
101
  });
107
102
  },
108
103
 
@@ -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?: GetActivePluginOptions,
664
+ options?: UseDataOptions,
664
665
  ) => ActivePlugin | undefined;
665
666
  export const useActivePluginAndVersion: (
666
- options?: GetActivePluginOptions,
667
+ options?: UseDataOptions,
667
668
  ) =>
668
669
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
669
670
  | undefined;
package/src/versions.ts CHANGED
@@ -133,7 +133,7 @@ export async function readVersionNames(
133
133
  return versions;
134
134
  }
135
135
 
136
- function getDocsDirPathLocalized({
136
+ export function getDocsDirPathLocalized({
137
137
  siteDir,
138
138
  locale,
139
139
  pluginId,
@@ -143,7 +143,7 @@ function getDocsDirPathLocalized({
143
143
  locale: string;
144
144
  pluginId: string;
145
145
  versionName: string;
146
- }) {
146
+ }): string {
147
147
  return getPluginI18nPath({
148
148
  siteDir,
149
149
  locale,