@docusaurus/plugin-content-docs 0.0.0-4378 → 0.0.0-4388

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,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
- import type { PathOptions, SidebarOptions } from './types';
7
+ import type { PathOptions, SidebarOptions } from '@docusaurus/plugin-content-docs';
8
8
  export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): void;
@@ -4,28 +4,9 @@
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, GlobalDoc } from '../types';
8
- declare type Version = GlobalVersion;
9
- declare type Doc = GlobalDoc;
10
- export declare type ActivePlugin = {
11
- pluginId: string;
12
- pluginData: GlobalPluginData;
13
- };
14
- export declare type GetActivePluginOptions = {
15
- failfast?: boolean;
16
- };
7
+ import type { GlobalPluginData, GlobalVersion, GetActivePluginOptions, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
17
8
  export declare function getActivePlugin(allPluginDatas: Record<string, GlobalPluginData>, pathname: string, options?: GetActivePluginOptions): ActivePlugin | undefined;
18
- export declare type ActiveDocContext = {
19
- activeVersion?: Version;
20
- activeDoc?: Doc;
21
- alternateDocVersions: Record<string, Doc>;
22
- };
23
- export declare const getLatestVersion: (data: GlobalPluginData) => Version;
24
- export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => Version | undefined;
9
+ export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
10
+ export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => GlobalVersion | undefined;
25
11
  export declare const getActiveDocContext: (data: GlobalPluginData, pathname: string) => ActiveDocContext;
26
- export declare type DocVersionSuggestions = {
27
- latestVersionSuggestion: GlobalVersion;
28
- latestDocSuggestion?: GlobalDoc;
29
- };
30
12
  export declare const getDocVersionSuggestions: (data: GlobalPluginData, pathname: string) => DocVersionSuggestions;
31
- export {};
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getDocVersionSuggestions = exports.getActiveDocContext = exports.getActiveVersion = exports.getLatestVersion = exports.getActivePlugin = void 0;
10
10
  const router_1 = require("@docusaurus/router");
11
+ // This code is not part of the api surface, not in ./theme on purpose
11
12
  // get the data of the plugin that is currently "active"
12
13
  // ie the docs of that plugin are currently browsed
13
14
  // it is useful to support multiple docs plugin instances
@@ -4,8 +4,7 @@
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 } from '../types';
8
- import { type ActivePlugin, type ActiveDocContext, type DocVersionSuggestions, type GetActivePluginOptions } from './docsClientUtils';
7
+ import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
9
8
  export declare const useAllDocsData: () => Record<string, GlobalPluginData>;
10
9
  export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
11
10
  export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
package/lib/docs.d.ts CHANGED
@@ -5,8 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext } from '@docusaurus/types';
8
- import type { DocFile, DocMetadataBase, MetadataOptions, PluginOptions, VersionMetadata, LoadedVersion } from './types';
8
+ import type { DocFile, DocMetadataBase, VersionMetadata, LoadedVersion } from './types';
9
9
  import type { SidebarsUtils } from './sidebars/utils';
10
+ import type { MetadataOptions, PluginOptions } from '@docusaurus/plugin-content-docs';
10
11
  declare type LastUpdateOptions = Pick<PluginOptions, 'showLastUpdateAuthor' | 'showLastUpdateTime'>;
11
12
  export declare function readDocFile(versionMetadata: Pick<VersionMetadata, 'contentPath' | 'contentPathLocalized'>, source: string, options: LastUpdateOptions): Promise<DocFile>;
12
13
  export declare function readVersionDocs(versionMetadata: VersionMetadata, options: Pick<PluginOptions, 'include' | 'exclude' | 'showLastUpdateAuthor' | 'showLastUpdateTime'>): Promise<DocFile[]>;
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { Sidebars } from './sidebars/types';
8
- import type { DocMetadata, GlobalDoc, LoadedVersion, GlobalVersion, GlobalSidebar } from './types';
8
+ import type { DocMetadata, LoadedVersion } from './types';
9
+ import type { GlobalVersion, GlobalSidebar, GlobalDoc } from '@docusaurus/plugin-content-docs/client';
9
10
  export declare function toGlobalDataDoc(doc: DocMetadata): GlobalDoc;
10
11
  export declare function toGlobalSidebars(sidebars: Sidebars, version: LoadedVersion): Record<string, GlobalSidebar>;
11
12
  export declare function toGlobalDataVersion(version: LoadedVersion): GlobalVersion;
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext, Plugin } from '@docusaurus/types';
8
- import type { PluginOptions, LoadedContent } from './types';
8
+ import type { LoadedContent } from './types';
9
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
9
10
  export default function pluginContentDocs(context: LoadContext, options: PluginOptions): Promise<Plugin<LoadedContent>>;
10
11
  export { validateOptions } from './options';
@@ -4,7 +4,7 @@
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 { NumberPrefixParser } from './types';
7
+ import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
8
8
  export declare const DefaultNumberPrefixParser: NumberPrefixParser;
9
9
  export declare const DisabledNumberPrefixParser: NumberPrefixParser;
10
10
  export declare function stripNumberPrefix(str: string, parser: NumberPrefixParser): string;
package/lib/options.d.ts CHANGED
@@ -4,7 +4,7 @@
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 { PluginOptions } from './types';
7
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
9
  import type { OptionValidationContext, ValidationResult } from '@docusaurus/types';
10
10
  export declare const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'>;
@@ -5,8 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { SidebarsConfig, Sidebars, NormalizedSidebars } from './types';
8
- import type { NormalizeSidebarsParams, PluginOptions } from '../types';
8
+ import type { NormalizeSidebarsParams } from '../types';
9
9
  import { type SidebarProcessorParams } from './processor';
10
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
10
11
  export declare const DefaultSidebars: SidebarsConfig;
11
12
  export declare const DisabledSidebars: SidebarsConfig;
12
13
  export declare function resolveSidebarPathOption(siteDir: string, sidebarPathOption: PluginOptions['sidebarPath']): PluginOptions['sidebarPath'];
@@ -4,9 +4,10 @@
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 { NumberPrefixParser, DocMetadataBase, VersionMetadata, SidebarOptions } from '../types';
7
+ import type { DocMetadataBase, VersionMetadata } from '../types';
8
8
  import type { Sidebars, NormalizedSidebars, SidebarItemsGeneratorOption } from './types';
9
9
  import type { Slugger } from '@docusaurus/utils';
10
+ import type { NumberPrefixParser, SidebarOptions } from '@docusaurus/plugin-content-docs';
10
11
  export declare type SidebarProcessorParams = {
11
12
  sidebarItemsGenerator: SidebarItemsGeneratorOption;
12
13
  numberPrefixParser: NumberPrefixParser;
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { Optional, Required } from 'utility-types';
8
- import type { DocMetadataBase, VersionMetadata, NumberPrefixParser, SidebarOptions } from '../types';
8
+ import type { DocMetadataBase, VersionMetadata } from '../types';
9
+ import type { NumberPrefixParser, SidebarOptions } from '@docusaurus/plugin-content-docs';
9
10
  declare type Expand<T extends Record<string, unknown>> = {
10
11
  [P in keyof T]: T[P];
11
12
  };
package/lib/slug.d.ts CHANGED
@@ -4,7 +4,8 @@
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 { DocMetadataBase, NumberPrefixParser } from './types';
7
+ import type { DocMetadataBase } from './types';
8
+ import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
8
9
  export default function getSlug({ baseID, frontmatterSlug, source, sourceDirName, stripDirNumberPrefixes, numberPrefixParser, }: {
9
10
  baseID: string;
10
11
  frontmatterSlug?: string;
package/lib/types.d.ts CHANGED
@@ -4,10 +4,10 @@
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 { RemarkAndRehypePluginOptions } from '@docusaurus/mdx-loader';
7
+ import type { Sidebars } from './sidebars/types';
8
8
  import type { Tag, FrontMatterTag, Slugger } from '@docusaurus/utils';
9
9
  import type { BrokenMarkdownLink as IBrokenMarkdownLink, ContentPaths } from '@docusaurus/utils/lib/markdownLinks';
10
- import type { SidebarItemsGeneratorOption, Sidebars } from './sidebars/types';
10
+ import type { VersionBanner, SidebarOptions } from '@docusaurus/plugin-content-docs';
11
11
  export declare type DocFile = {
12
12
  contentPath: string;
13
13
  filePath: string;
@@ -15,9 +15,8 @@ export declare type DocFile = {
15
15
  content: string;
16
16
  lastUpdate: LastUpdateData;
17
17
  };
18
- export declare type VersionName = string;
19
18
  export declare type VersionMetadata = ContentPaths & {
20
- versionName: VersionName;
19
+ versionName: string;
21
20
  versionLabel: string;
22
21
  versionPath: string;
23
22
  tagsPath: string;
@@ -30,62 +29,10 @@ export declare type VersionMetadata = ContentPaths & {
30
29
  sidebarFilePath: string | false | undefined;
31
30
  routePriority: number | undefined;
32
31
  };
33
- export declare type EditUrlFunction = (editUrlParams: {
34
- version: string;
35
- versionDocsDirPath: string;
36
- docPath: string;
37
- permalink: string;
38
- locale: string;
39
- }) => string | undefined;
40
- export declare type MetadataOptions = {
41
- routeBasePath: string;
42
- editUrl?: string | EditUrlFunction;
43
- editCurrentVersion: boolean;
44
- editLocalizedFiles: boolean;
45
- showLastUpdateTime?: boolean;
46
- showLastUpdateAuthor?: boolean;
47
- numberPrefixParser: NumberPrefixParser;
48
- };
49
- export declare type PathOptions = {
50
- path: string;
51
- sidebarPath?: string | false | undefined;
52
- };
53
- export declare type VersionBanner = 'unreleased' | 'unmaintained';
54
- export declare type VersionOptions = {
55
- path?: string;
56
- label?: string;
57
- banner?: 'none' | VersionBanner;
58
- badge?: boolean;
59
- className?: string;
60
- };
61
- export declare type VersionsOptions = {
62
- lastVersion?: string;
63
- versions: Record<string, VersionOptions>;
64
- onlyIncludeVersions?: string[];
65
- };
66
- export declare type SidebarOptions = {
67
- sidebarCollapsible: boolean;
68
- sidebarCollapsed: boolean;
69
- };
70
32
  export declare type NormalizeSidebarsParams = SidebarOptions & {
71
33
  version: VersionMetadata;
72
34
  categoryLabelSlugger: Slugger;
73
35
  };
74
- export declare type PluginOptions = MetadataOptions & PathOptions & VersionsOptions & RemarkAndRehypePluginOptions & SidebarOptions & {
75
- id: string;
76
- include: string[];
77
- exclude: string[];
78
- docLayoutComponent: string;
79
- docItemComponent: string;
80
- docTagDocListComponent: string;
81
- docTagsListComponent: string;
82
- docCategoryGeneratedIndexComponent: string;
83
- admonitions: Record<string, unknown>;
84
- disableVersioning: boolean;
85
- includeCurrentVersion: boolean;
86
- sidebarItemsGenerator: SidebarItemsGeneratorOption;
87
- tagsBasePath: string;
88
- };
89
36
  export declare type LastUpdateData = {
90
37
  lastUpdatedAt?: number;
91
38
  formattedLastUpdatedAt?: string;
@@ -115,7 +62,7 @@ export declare type DocFrontMatter = {
115
62
  export declare type DocMetadataBase = LastUpdateData & {
116
63
  id: string;
117
64
  unversionedId: string;
118
- version: VersionName;
65
+ version: string;
119
66
  title: string;
120
67
  description: string;
121
68
  source: string;
@@ -168,31 +115,6 @@ export declare type LoadedVersion = VersionMetadata & {
168
115
  export declare type LoadedContent = {
169
116
  loadedVersions: LoadedVersion[];
170
117
  };
171
- export declare type GlobalDoc = {
172
- id: string;
173
- path: string;
174
- sidebar: string | undefined;
175
- };
176
- export declare type GlobalVersion = {
177
- name: VersionName;
178
- label: string;
179
- isLast: boolean;
180
- path: string;
181
- mainDocId: string;
182
- docs: GlobalDoc[];
183
- sidebars?: Record<string, GlobalSidebar>;
184
- };
185
- export declare type GlobalSidebarLink = {
186
- label: string;
187
- path: string;
188
- };
189
- export declare type GlobalSidebar = {
190
- link?: GlobalSidebarLink;
191
- };
192
- export declare type GlobalPluginData = {
193
- path: string;
194
- versions: GlobalVersion[];
195
- };
196
118
  export declare type BrokenMarkdownLink = IBrokenMarkdownLink<VersionMetadata>;
197
119
  export declare type DocsMarkdownOption = {
198
120
  versionsMetadata: VersionMetadata[];
@@ -200,7 +122,3 @@ export declare type DocsMarkdownOption = {
200
122
  sourceToPermalink: SourceToPermalink;
201
123
  onBrokenMarkdownLink: (brokenMarkdownLink: BrokenMarkdownLink) => void;
202
124
  };
203
- export declare type NumberPrefixParser = (filename: string) => {
204
- filename: string;
205
- numberPrefix?: number;
206
- };
package/lib/versions.d.ts CHANGED
@@ -4,7 +4,8 @@
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 { PluginOptions, VersionMetadata } from './types';
7
+ import type { VersionMetadata } from './types';
8
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
9
  import type { LoadContext } from '@docusaurus/types';
9
10
  export declare function getVersionedDocsDirPath(siteDir: string, pluginId: string): string;
10
11
  export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4378",
3
+ "version": "0.0.0-4388",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/core": "0.0.0-4378",
26
- "@docusaurus/logger": "0.0.0-4378",
27
- "@docusaurus/mdx-loader": "0.0.0-4378",
28
- "@docusaurus/utils": "0.0.0-4378",
29
- "@docusaurus/utils-validation": "0.0.0-4378",
25
+ "@docusaurus/core": "0.0.0-4388",
26
+ "@docusaurus/logger": "0.0.0-4388",
27
+ "@docusaurus/mdx-loader": "0.0.0-4388",
28
+ "@docusaurus/utils": "0.0.0-4388",
29
+ "@docusaurus/utils-validation": "0.0.0-4388",
30
30
  "combine-promises": "^1.1.0",
31
31
  "escape-string-regexp": "^4.0.0",
32
32
  "fs-extra": "^10.0.0",
@@ -42,8 +42,8 @@
42
42
  "webpack": "^5.61.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4378",
46
- "@docusaurus/types": "0.0.0-4378",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4388",
46
+ "@docusaurus/types": "0.0.0-4388",
47
47
  "@types/js-yaml": "^4.0.0",
48
48
  "@types/picomatch": "^2.2.1",
49
49
  "commander": "^5.1.0",
@@ -57,5 +57,5 @@
57
57
  "engines": {
58
58
  "node": ">=14"
59
59
  },
60
- "gitHead": "bd7999376fa63feafe5b169296beb91dac362954"
60
+ "gitHead": "73aaa086302e31cf9e6dd3c95b55ab91c1961f2f"
61
61
  }
package/src/cli.ts CHANGED
@@ -12,7 +12,10 @@ import {
12
12
  } from './versions';
13
13
  import fs from 'fs-extra';
14
14
  import path from 'path';
15
- import type {PathOptions, SidebarOptions} from './types';
15
+ import type {
16
+ PathOptions,
17
+ SidebarOptions,
18
+ } from '@docusaurus/plugin-content-docs';
16
19
  import {loadSidebarsFile, resolveSidebarPathOption} from './sidebars';
17
20
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
18
21
  import logger from '@docusaurus/logger';
@@ -7,21 +7,18 @@
7
7
 
8
8
  import {matchPath} from '@docusaurus/router';
9
9
 
10
- import type {GlobalPluginData, GlobalVersion, GlobalDoc} from '../types';
10
+ import type {
11
+ GlobalPluginData,
12
+ GlobalVersion,
13
+ GlobalDoc,
14
+ GetActivePluginOptions,
15
+ ActivePlugin,
16
+ ActiveDocContext,
17
+ DocVersionSuggestions,
18
+ } from '@docusaurus/plugin-content-docs/client';
11
19
 
12
20
  // This code is not part of the api surface, not in ./theme on purpose
13
21
 
14
- // Short/convenient type aliases
15
- type Version = GlobalVersion;
16
- type Doc = GlobalDoc;
17
-
18
- export type ActivePlugin = {
19
- pluginId: string;
20
- pluginData: GlobalPluginData;
21
- };
22
-
23
- export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
24
-
25
22
  // get the data of the plugin that is currently "active"
26
23
  // ie the docs of that plugin are currently browsed
27
24
  // it is useful to support multiple docs plugin instances
@@ -56,13 +53,7 @@ export function getActivePlugin(
56
53
  return activePlugin;
57
54
  }
58
55
 
59
- export type ActiveDocContext = {
60
- activeVersion?: Version;
61
- activeDoc?: Doc;
62
- alternateDocVersions: Record<string, Doc>;
63
- };
64
-
65
- export const getLatestVersion = (data: GlobalPluginData): Version =>
56
+ export const getLatestVersion = (data: GlobalPluginData): GlobalVersion =>
66
57
  data.versions.find((version) => version.isLast)!;
67
58
 
68
59
  // Note: return undefined on doc-unrelated pages,
@@ -70,7 +61,7 @@ export const getLatestVersion = (data: GlobalPluginData): Version =>
70
61
  export const getActiveVersion = (
71
62
  data: GlobalPluginData,
72
63
  pathname: string,
73
- ): Version | undefined => {
64
+ ): GlobalVersion | undefined => {
74
65
  const lastVersion = getLatestVersion(data);
75
66
  // Last version is a route like /docs/*,
76
67
  // we need to try to match it last or it would match /docs/version-1.0/* as well
@@ -127,13 +118,6 @@ export const getActiveDocContext = (
127
118
  };
128
119
  };
129
120
 
130
- export type DocVersionSuggestions = {
131
- // suggest the latest version
132
- latestVersionSuggestion: GlobalVersion;
133
- // suggest the same doc, in latest version (if exist)
134
- latestDocSuggestion?: GlobalDoc;
135
- };
136
-
137
121
  export const getDocVersionSuggestions = (
138
122
  data: GlobalPluginData,
139
123
  pathname: string,
@@ -11,18 +11,21 @@ import useGlobalData, {
11
11
  usePluginData,
12
12
  } from '@docusaurus/useGlobalData';
13
13
 
14
- import type {GlobalPluginData, GlobalVersion} from '../types';
15
14
  import {
16
15
  getActivePlugin,
17
16
  getLatestVersion,
18
17
  getActiveVersion,
19
18
  getActiveDocContext,
20
19
  getDocVersionSuggestions,
21
- type ActivePlugin,
22
- type ActiveDocContext,
23
- type DocVersionSuggestions,
24
- type GetActivePluginOptions,
25
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';
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
package/src/docs.ts CHANGED
@@ -28,8 +28,6 @@ import type {
28
28
  DocMetadata,
29
29
  DocNavLink,
30
30
  LastUpdateData,
31
- MetadataOptions,
32
- PluginOptions,
33
31
  VersionMetadata,
34
32
  LoadedVersion,
35
33
  } from './types';
@@ -40,6 +38,10 @@ import {stripPathNumberPrefixes} from './numberPrefix';
40
38
  import {validateDocFrontMatter} from './docFrontMatter';
41
39
  import type {SidebarsUtils} from './sidebars/utils';
42
40
  import {toDocNavigationLink, toNavigationLink} from './sidebars/utils';
41
+ import type {
42
+ MetadataOptions,
43
+ PluginOptions,
44
+ } from '@docusaurus/plugin-content-docs';
43
45
 
44
46
  type LastUpdateOptions = Pick<
45
47
  PluginOptions,
package/src/globalData.ts CHANGED
@@ -9,13 +9,12 @@ import {mapValues} from 'lodash';
9
9
  import {normalizeUrl} from '@docusaurus/utils';
10
10
  import type {Sidebars} from './sidebars/types';
11
11
  import {createSidebarsUtils} from './sidebars/utils';
12
+ import type {DocMetadata, LoadedVersion} from './types';
12
13
  import type {
13
- DocMetadata,
14
- GlobalDoc,
15
- LoadedVersion,
16
14
  GlobalVersion,
17
15
  GlobalSidebar,
18
- } from './types';
16
+ GlobalDoc,
17
+ } from '@docusaurus/plugin-content-docs/client';
19
18
 
20
19
  export function toGlobalDataDoc(doc: DocMetadata): GlobalDoc {
21
20
  return {
package/src/index.ts CHANGED
@@ -30,11 +30,9 @@ import {
30
30
  import {getDocsDirPaths, readVersionsMetadata} from './versions';
31
31
 
32
32
  import type {
33
- PluginOptions,
34
33
  LoadedContent,
35
34
  SourceToPermalink,
36
35
  DocMetadataBase,
37
- GlobalPluginData,
38
36
  VersionMetadata,
39
37
  LoadedVersion,
40
38
  DocFile,
@@ -54,7 +52,11 @@ import {
54
52
  import logger from '@docusaurus/logger';
55
53
  import {getVersionTags} from './tags';
56
54
  import {createVersionRoutes} from './routes';
57
- import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
55
+ import type {
56
+ PropTagsListPage,
57
+ PluginOptions,
58
+ } from '@docusaurus/plugin-content-docs';
59
+ import type {GlobalPluginData} from '@docusaurus/plugin-content-docs/client';
58
60
  import {createSidebarsUtils} from './sidebars/utils';
59
61
  import {getCategoryGeneratedIndexMetadataList} from './categoryGeneratedIndex';
60
62
 
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {NumberPrefixParser} from './types';
8
+ import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
9
9
 
10
10
  // Best-effort to avoid parsing some patterns as number prefix
11
11
  const IgnoredPrefixPatterns = (function () {
package/src/options.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {PluginOptions} from './types';
8
+ import type {PluginOptions} from '@docusaurus/plugin-content-docs';
9
9
  import {
10
10
  Joi,
11
11
  RemarkPluginsSchema,
@@ -6,15 +6,76 @@
6
6
  */
7
7
 
8
8
  declare module '@docusaurus/plugin-content-docs' {
9
- export type Options = Partial<import('./types').PluginOptions>;
10
- export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
11
- export type VersionBanner = import('./types').VersionBanner;
12
- type GlobalDataVersion = import('./types').GlobalVersion;
13
- type GlobalDataDoc = import('./types').GlobalDoc;
14
- type GlobalDataSidebar = import('./types').GlobalSidebar;
15
- type VersionTag = import('./types').VersionTag;
9
+ import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
10
+
11
+ export type NumberPrefixParser = (filename: string) => {
12
+ filename: string;
13
+ numberPrefix?: number;
14
+ };
15
+
16
+ export type EditUrlFunction = (editUrlParams: {
17
+ version: string;
18
+ versionDocsDirPath: string;
19
+ docPath: string;
20
+ permalink: string;
21
+ locale: string;
22
+ }) => string | undefined;
23
+
24
+ export type MetadataOptions = {
25
+ routeBasePath: string;
26
+ editUrl?: string | EditUrlFunction;
27
+ editCurrentVersion: boolean;
28
+ editLocalizedFiles: boolean;
29
+ showLastUpdateTime?: boolean;
30
+ showLastUpdateAuthor?: boolean;
31
+ numberPrefixParser: NumberPrefixParser;
32
+ };
33
+
34
+ export type PathOptions = {
35
+ path: string;
36
+ sidebarPath?: string | false | undefined;
37
+ };
38
+
39
+ // TODO support custom version banner? {type: "error", content: "html content"}
40
+ export type VersionBanner = 'unreleased' | 'unmaintained';
41
+ export type VersionOptions = {
42
+ path?: string;
43
+ label?: string;
44
+ banner?: 'none' | VersionBanner;
45
+ badge?: boolean;
46
+ className?: string;
47
+ };
48
+ export type VersionsOptions = {
49
+ lastVersion?: string;
50
+ versions: Record<string, VersionOptions>;
51
+ onlyIncludeVersions?: string[];
52
+ };
53
+ export type SidebarOptions = {
54
+ sidebarCollapsible: boolean;
55
+ sidebarCollapsed: boolean;
56
+ };
16
57
 
17
- export type {GlobalDataVersion, GlobalDataDoc, GlobalDataSidebar};
58
+ export type PluginOptions = MetadataOptions &
59
+ PathOptions &
60
+ VersionsOptions &
61
+ RemarkAndRehypePluginOptions &
62
+ SidebarOptions & {
63
+ id: string;
64
+ include: string[];
65
+ exclude: string[];
66
+ docLayoutComponent: string;
67
+ docItemComponent: string;
68
+ docTagDocListComponent: string;
69
+ docTagsListComponent: string;
70
+ docCategoryGeneratedIndexComponent: string;
71
+ admonitions: Record<string, unknown>;
72
+ disableVersioning: boolean;
73
+ includeCurrentVersion: boolean;
74
+ sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
75
+ tagsBasePath: string;
76
+ };
77
+ export type Options = Partial<PluginOptions>;
78
+ export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
18
79
 
19
80
  export type PropNavigationLink = {
20
81
  readonly title: string;
@@ -241,18 +302,54 @@ declare module '@theme/Seo' {
241
302
  export default Seo;
242
303
  }
243
304
 
244
- // TODO can't we infer types directly from code?
305
+ // TODO until TS supports exports field... hope it's in 4.6
245
306
  declare module '@docusaurus/plugin-content-docs/client' {
246
- type GlobalPluginData = import('./types').GlobalPluginData;
247
- type GlobalVersion = import('./types').GlobalVersion;
248
- type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
249
- type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
250
- type DocVersionSuggestions =
251
- import('./client/docsClientUtils').DocVersionSuggestions;
252
- type GetActivePluginOptions =
253
- import('./client/docsClientUtils').GetActivePluginOptions;
254
-
255
- export type {GlobalPluginData, GlobalVersion};
307
+ export type ActivePlugin = {
308
+ pluginId: string;
309
+ pluginData: GlobalPluginData;
310
+ };
311
+ export type ActiveDocContext = {
312
+ activeVersion?: GlobalVersion;
313
+ activeDoc?: GlobalDoc;
314
+ alternateDocVersions: Record<string, GlobalDoc>;
315
+ };
316
+ export type GlobalDoc = {
317
+ id: string;
318
+ path: string;
319
+ sidebar: string | undefined;
320
+ };
321
+
322
+ export type GlobalVersion = {
323
+ name: string;
324
+ label: string;
325
+ isLast: boolean;
326
+ path: string;
327
+ mainDocId: string; // home doc (if docs homepage configured), or first doc
328
+ docs: GlobalDoc[];
329
+ sidebars?: Record<string, GlobalSidebar>;
330
+ };
331
+
332
+ export type GlobalSidebarLink = {
333
+ label: string;
334
+ path: string;
335
+ };
336
+
337
+ export type GlobalSidebar = {
338
+ link?: GlobalSidebarLink;
339
+ // ... we may add other things here later
340
+ };
341
+ export type GlobalPluginData = {
342
+ path: string;
343
+ versions: GlobalVersion[];
344
+ };
345
+ export type DocVersionSuggestions = {
346
+ // suggest the latest version
347
+ latestVersionSuggestion: GlobalVersion;
348
+ // suggest the same doc, in latest version (if exist)
349
+ latestDocSuggestion?: GlobalDoc;
350
+ };
351
+ export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
352
+
256
353
  export const useAllDocsData: () => Record<string, GlobalPluginData>;
257
354
  export const useDocsData: (pluginId?: string) => GlobalPluginData;
258
355
  export const useActivePlugin: (
@@ -8,12 +8,13 @@
8
8
  import fs from 'fs-extra';
9
9
  import importFresh from 'import-fresh';
10
10
  import type {SidebarsConfig, Sidebars, NormalizedSidebars} from './types';
11
- import type {NormalizeSidebarsParams, PluginOptions} from '../types';
11
+ import type {NormalizeSidebarsParams} from '../types';
12
12
  import {validateSidebars} from './validation';
13
13
  import {normalizeSidebars} from './normalization';
14
14
  import {processSidebars, type SidebarProcessorParams} from './processor';
15
15
  import path from 'path';
16
16
  import {createSlugger} from '@docusaurus/utils';
17
+ import type {PluginOptions} from '@docusaurus/plugin-content-docs';
17
18
 
18
19
  export const DefaultSidebars: SidebarsConfig = {
19
20
  defaultSidebar: [
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {NormalizeSidebarsParams, SidebarOptions} from '../types';
8
+ import type {NormalizeSidebarsParams} from '../types';
9
9
  import type {
10
10
  NormalizedSidebarItem,
11
11
  NormalizedSidebar,
@@ -21,6 +21,7 @@ import type {
21
21
  import {isCategoriesShorthand} from './utils';
22
22
  import {mapValues} from 'lodash';
23
23
  import {normalizeUrl} from '@docusaurus/utils';
24
+ import type {SidebarOptions} from '@docusaurus/plugin-content-docs';
24
25
 
25
26
  function normalizeCategoryLink(
26
27
  category: SidebarItemCategoryConfig,
@@ -5,12 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {
9
- NumberPrefixParser,
10
- DocMetadataBase,
11
- VersionMetadata,
12
- SidebarOptions,
13
- } from '../types';
8
+ import type {DocMetadataBase, VersionMetadata} from '../types';
14
9
  import type {
15
10
  Sidebars,
16
11
  Sidebar,
@@ -31,6 +26,10 @@ import {mapValues, memoize, pick} from 'lodash';
31
26
  import combinePromises from 'combine-promises';
32
27
  import {normalizeItem} from './normalization';
33
28
  import type {Slugger} from '@docusaurus/utils';
29
+ import type {
30
+ NumberPrefixParser,
31
+ SidebarOptions,
32
+ } from '@docusaurus/plugin-content-docs';
34
33
 
35
34
  export type SidebarProcessorParams = {
36
35
  sidebarItemsGenerator: SidebarItemsGeneratorOption;
@@ -6,12 +6,11 @@
6
6
  */
7
7
 
8
8
  import type {Optional, Required} from 'utility-types';
9
+ import type {DocMetadataBase, VersionMetadata} from '../types';
9
10
  import type {
10
- DocMetadataBase,
11
- VersionMetadata,
12
11
  NumberPrefixParser,
13
12
  SidebarOptions,
14
- } from '../types';
13
+ } from '@docusaurus/plugin-content-docs';
15
14
 
16
15
  // Makes all properties visible when hovering over the type
17
16
  type Expand<T extends Record<string, unknown>> = {[P in keyof T]: T[P]};
package/src/slug.ts CHANGED
@@ -15,8 +15,9 @@ import {
15
15
  DefaultNumberPrefixParser,
16
16
  stripPathNumberPrefixes,
17
17
  } from './numberPrefix';
18
- import type {DocMetadataBase, NumberPrefixParser} from './types';
18
+ import type {DocMetadataBase} from './types';
19
19
  import {isConventionalDocIndex} from './docs';
20
+ import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
20
21
 
21
22
  export default function getSlug({
22
23
  baseID,
package/src/types.ts CHANGED
@@ -7,13 +7,16 @@
7
7
 
8
8
  /// <reference types="@docusaurus/module-type-aliases" />
9
9
 
10
- import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
10
+ import type {Sidebars} from './sidebars/types';
11
11
  import type {Tag, FrontMatterTag, Slugger} from '@docusaurus/utils';
12
12
  import type {
13
13
  BrokenMarkdownLink as IBrokenMarkdownLink,
14
14
  ContentPaths,
15
15
  } from '@docusaurus/utils/lib/markdownLinks';
16
- import type {SidebarItemsGeneratorOption, Sidebars} from './sidebars/types';
16
+ import type {
17
+ VersionBanner,
18
+ SidebarOptions,
19
+ } from '@docusaurus/plugin-content-docs';
17
20
 
18
21
  export type DocFile = {
19
22
  contentPath: string; // /!\ may be localized
@@ -23,10 +26,8 @@ export type DocFile = {
23
26
  lastUpdate: LastUpdateData;
24
27
  };
25
28
 
26
- export type VersionName = string;
27
-
28
29
  export type VersionMetadata = ContentPaths & {
29
- versionName: VersionName; // 1.0.0
30
+ versionName: string; // 1.0.0
30
31
  versionLabel: string; // Version 1.0.0
31
32
  versionPath: string; // /baseUrl/docs/1.0.0
32
33
  tagsPath: string;
@@ -40,76 +41,11 @@ export type VersionMetadata = ContentPaths & {
40
41
  routePriority: number | undefined; // -1 for the latest docs
41
42
  };
42
43
 
43
- export type EditUrlFunction = (editUrlParams: {
44
- version: string;
45
- versionDocsDirPath: string;
46
- docPath: string;
47
- permalink: string;
48
- locale: string;
49
- }) => string | undefined;
50
-
51
- export type MetadataOptions = {
52
- routeBasePath: string;
53
- editUrl?: string | EditUrlFunction;
54
- editCurrentVersion: boolean;
55
- editLocalizedFiles: boolean;
56
- showLastUpdateTime?: boolean;
57
- showLastUpdateAuthor?: boolean;
58
- numberPrefixParser: NumberPrefixParser;
59
- };
60
-
61
- export type PathOptions = {
62
- path: string;
63
- sidebarPath?: string | false | undefined;
64
- };
65
-
66
- // TODO support custom version banner? {type: "error", content: "html content"}
67
- export type VersionBanner = 'unreleased' | 'unmaintained';
68
-
69
- export type VersionOptions = {
70
- path?: string;
71
- label?: string;
72
- banner?: 'none' | VersionBanner;
73
- badge?: boolean;
74
- className?: string;
75
- };
76
-
77
- export type VersionsOptions = {
78
- lastVersion?: string;
79
- versions: Record<string, VersionOptions>;
80
- onlyIncludeVersions?: string[];
81
- };
82
-
83
- export type SidebarOptions = {
84
- sidebarCollapsible: boolean;
85
- sidebarCollapsed: boolean;
86
- };
87
-
88
44
  export type NormalizeSidebarsParams = SidebarOptions & {
89
45
  version: VersionMetadata;
90
46
  categoryLabelSlugger: Slugger;
91
47
  };
92
48
 
93
- export type PluginOptions = MetadataOptions &
94
- PathOptions &
95
- VersionsOptions &
96
- RemarkAndRehypePluginOptions &
97
- SidebarOptions & {
98
- id: string;
99
- include: string[];
100
- exclude: string[];
101
- docLayoutComponent: string;
102
- docItemComponent: string;
103
- docTagDocListComponent: string;
104
- docTagsListComponent: string;
105
- docCategoryGeneratedIndexComponent: string;
106
- admonitions: Record<string, unknown>;
107
- disableVersioning: boolean;
108
- includeCurrentVersion: boolean;
109
- sidebarItemsGenerator: SidebarItemsGeneratorOption;
110
- tagsBasePath: string;
111
- };
112
-
113
49
  export type LastUpdateData = {
114
50
  lastUpdatedAt?: number;
115
51
  formattedLastUpdatedAt?: string;
@@ -142,7 +78,7 @@ export type DocFrontMatter = {
142
78
  export type DocMetadataBase = LastUpdateData & {
143
79
  id: string; // TODO legacy versioned id => try to remove
144
80
  unversionedId: string; // TODO new unversioned id => try to rename to "id"
145
- version: VersionName;
81
+ version: string;
146
82
  title: string;
147
83
  description: string;
148
84
  source: string; // @site aliased source => "@site/docs/folder/subFolder/subSubFolder/myDoc.md"
@@ -203,37 +139,6 @@ export type LoadedContent = {
203
139
  loadedVersions: LoadedVersion[];
204
140
  };
205
141
 
206
- export type GlobalDoc = {
207
- id: string;
208
- path: string;
209
- sidebar: string | undefined;
210
- };
211
-
212
- export type GlobalVersion = {
213
- name: VersionName;
214
- label: string;
215
- isLast: boolean;
216
- path: string;
217
- mainDocId: string; // home doc (if docs homepage configured), or first doc
218
- docs: GlobalDoc[];
219
- sidebars?: Record<string, GlobalSidebar>;
220
- };
221
-
222
- export type GlobalSidebarLink = {
223
- label: string;
224
- path: string;
225
- };
226
-
227
- export type GlobalSidebar = {
228
- link?: GlobalSidebarLink;
229
- // ... we may add other things here later
230
- };
231
-
232
- export type GlobalPluginData = {
233
- path: string;
234
- versions: GlobalVersion[];
235
- };
236
-
237
142
  export type BrokenMarkdownLink = IBrokenMarkdownLink<VersionMetadata>;
238
143
 
239
144
  export type DocsMarkdownOption = {
@@ -242,8 +147,3 @@ export type DocsMarkdownOption = {
242
147
  sourceToPermalink: SourceToPermalink;
243
148
  onBrokenMarkdownLink: (brokenMarkdownLink: BrokenMarkdownLink) => void;
244
149
  };
245
-
246
- export type NumberPrefixParser = (filename: string) => {
247
- filename: string;
248
- numberPrefix?: number;
249
- };
package/src/versions.ts CHANGED
@@ -7,19 +7,19 @@
7
7
 
8
8
  import path from 'path';
9
9
  import fs from 'fs-extra';
10
- import type {
11
- PluginOptions,
12
- VersionBanner,
13
- VersionMetadata,
14
- VersionOptions,
15
- VersionsOptions,
16
- } from './types';
10
+ import type {VersionMetadata} from './types';
17
11
  import {
18
12
  VERSIONS_JSON_FILE,
19
13
  VERSIONED_DOCS_DIR,
20
14
  VERSIONED_SIDEBARS_DIR,
21
15
  CURRENT_VERSION_NAME,
22
16
  } from './constants';
17
+ import type {
18
+ PluginOptions,
19
+ VersionBanner,
20
+ VersionOptions,
21
+ VersionsOptions,
22
+ } from '@docusaurus/plugin-content-docs';
23
23
 
24
24
  import type {LoadContext} from '@docusaurus/types';
25
25
  import {