@docusaurus/plugin-content-docs 2.0.0-beta.15d451942 → 2.0.0-beta.18
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/categoryGeneratedIndex.d.ts +12 -0
- package/lib/categoryGeneratedIndex.js +35 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +37 -51
- package/lib/client/docsClientUtils.d.ts +6 -26
- package/lib/client/docsClientUtils.js +28 -34
- package/lib/{theme/hooks/useDocs.d.ts → client/index.d.ts} +4 -3
- package/lib/{theme/hooks/useDocs.js → client/index.js} +28 -25
- package/lib/docs.d.ts +31 -4
- package/lib/docs.js +160 -54
- package/{src/__tests__/__fixtures__/simple-site/docusaurus.config.js → lib/frontMatter.d.ts} +4 -8
- package/lib/{docFrontMatter.js → frontMatter.js} +13 -6
- package/lib/globalData.d.ts +2 -2
- package/lib/globalData.js +32 -3
- package/lib/index.d.ts +4 -3
- package/lib/index.js +123 -136
- package/lib/lastUpdate.d.ts +4 -6
- package/lib/lastUpdate.js +22 -26
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.d.ts +1 -1
- package/lib/markdown/linkify.js +7 -3
- package/lib/numberPrefix.d.ts +1 -1
- package/lib/numberPrefix.js +16 -21
- package/lib/options.d.ts +3 -5
- package/lib/options.js +55 -19
- package/lib/props.d.ts +7 -2
- package/lib/props.js +70 -14
- package/lib/routes.d.ts +28 -0
- package/lib/routes.js +110 -0
- package/lib/server-export.d.ts +8 -0
- package/lib/server-export.js +23 -0
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -6
- package/lib/sidebars/generator.js +209 -0
- package/lib/sidebars/index.d.ts +13 -0
- package/lib/sidebars/index.js +94 -0
- package/lib/sidebars/normalization.d.ts +13 -0
- package/lib/sidebars/normalization.js +55 -0
- package/lib/sidebars/postProcessor.d.ts +8 -0
- package/lib/sidebars/postProcessor.js +65 -0
- package/lib/sidebars/processor.d.ts +10 -0
- package/lib/sidebars/processor.js +79 -0
- package/lib/sidebars/types.d.ts +174 -0
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
- package/lib/sidebars/utils.d.ts +54 -0
- package/lib/sidebars/utils.js +255 -0
- package/lib/sidebars/validation.d.ts +11 -0
- package/lib/sidebars/validation.js +138 -0
- package/lib/slug.d.ts +6 -4
- package/lib/slug.js +29 -19
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js → lib/tags.d.ts} +2 -8
- package/lib/tags.js +21 -0
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +89 -49
- package/lib/types.d.ts +60 -130
- package/lib/versions.d.ts +29 -4
- package/lib/versions.js +134 -97
- package/package.json +30 -26
- package/src/categoryGeneratedIndex.ts +55 -0
- package/src/cli.ts +47 -63
- package/src/client/docsClientUtils.ts +38 -73
- package/src/{theme/hooks/useDocs.ts → client/index.ts} +16 -11
- package/{types.d.ts → src/deps.d.ts} +1 -1
- package/src/docs.ts +212 -46
- package/src/{docFrontMatter.ts → frontMatter.ts} +21 -26
- package/src/globalData.ts +53 -3
- package/src/index.ts +168 -178
- package/src/lastUpdate.ts +26 -33
- package/src/markdown/index.ts +10 -16
- package/src/markdown/linkify.ts +6 -2
- package/src/numberPrefix.ts +19 -26
- package/src/options.ts +60 -32
- package/src/plugin-content-docs.d.ts +263 -40
- package/src/props.ts +105 -21
- package/src/routes.ts +185 -0
- package/src/server-export.ts +24 -0
- package/src/sidebars/README.md +9 -0
- package/src/sidebars/generator.ts +292 -0
- package/src/sidebars/index.ts +120 -0
- package/src/sidebars/normalization.ts +85 -0
- package/src/sidebars/postProcessor.ts +89 -0
- package/src/sidebars/processor.ts +120 -0
- package/src/sidebars/types.ts +274 -0
- package/src/sidebars/utils.ts +388 -0
- package/src/sidebars/validation.ts +174 -0
- package/src/slug.ts +40 -23
- package/src/tags.ts +19 -0
- package/src/translations.ts +124 -66
- package/src/types.ts +67 -187
- package/src/versions.ts +205 -110
- package/lib/.tsbuildinfo +0 -4717
- package/lib/docFrontMatter.d.ts +0 -21
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -42
- package/lib/sidebars.js +0 -309
- package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
- package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
- package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
- package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
- package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
- package/src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
- package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
- package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
- package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -67
- package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -52
- package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
- package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
- package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
- package/src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
- package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
- package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
- package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1907
- package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -487
- package/src/__tests__/cli.test.ts +0 -333
- package/src/__tests__/docFrontMatter.test.ts +0 -204
- package/src/__tests__/docs.test.ts +0 -875
- package/src/__tests__/index.test.ts +0 -1831
- package/src/__tests__/lastUpdate.test.ts +0 -68
- package/src/__tests__/numberPrefix.test.ts +0 -199
- package/src/__tests__/options.test.ts +0 -232
- package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
- package/src/__tests__/sidebars.test.ts +0 -638
- package/src/__tests__/slug.test.ts +0 -109
- package/src/__tests__/translations.test.ts +0 -159
- package/src/__tests__/versions.test.ts +0 -718
- package/src/client/__tests__/docsClientUtils.test.ts +0 -372
- package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
- package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
- package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
- package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
- package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
- package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
- package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
- package/src/markdown/__tests__/linkify.test.ts +0 -190
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -489
- package/tsconfig.json +0 -9
package/src/numberPrefix.ts
CHANGED
|
@@ -5,43 +5,36 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {NumberPrefixParser} from '
|
|
8
|
+
import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
|
|
9
9
|
|
|
10
10
|
// Best-effort to avoid parsing some patterns as number prefix
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`${DateLikePrefixRegex.source}|${VersionLikePrefixRegex.source}`,
|
|
23
|
-
);
|
|
24
|
-
})();
|
|
25
|
-
|
|
26
|
-
const NumberPrefixRegex = /^(?<numberPrefix>\d+)(?<separator>\s*[-_.]+\s*)(?<suffix>.*)$/;
|
|
11
|
+
// ignore common date-like patterns: https://github.com/facebook/docusaurus/issues/4640
|
|
12
|
+
// ignore common versioning patterns: https://github.com/facebook/docusaurus/issues/4653
|
|
13
|
+
// Both of them would look like 7.0-foo or 2021-11-foo
|
|
14
|
+
// note: we could try to parse float numbers in filenames, but that is probably
|
|
15
|
+
// not worth it, as a version such as "8.0" can be interpreted as either a
|
|
16
|
+
// version or a float. User can configure her own NumberPrefixParser if she
|
|
17
|
+
// wants 8.0 to be interpreted as a float
|
|
18
|
+
const ignoredPrefixPattern = /^\d+[-_.]\d+/;
|
|
19
|
+
|
|
20
|
+
const numberPrefixPattern =
|
|
21
|
+
/^(?<numberPrefix>\d+)\s*[-_.]+\s*(?<suffix>[^-_.\s].*)$/;
|
|
27
22
|
|
|
28
23
|
// 0-myDoc => {filename: myDoc, numberPrefix: 0}
|
|
29
24
|
// 003 - myDoc => {filename: myDoc, numberPrefix: 3}
|
|
30
25
|
export const DefaultNumberPrefixParser: NumberPrefixParser = (
|
|
31
26
|
filename: string,
|
|
32
27
|
) => {
|
|
33
|
-
if (
|
|
28
|
+
if (ignoredPrefixPattern.test(filename)) {
|
|
29
|
+
return {filename, numberPrefix: undefined};
|
|
30
|
+
}
|
|
31
|
+
const match = numberPrefixPattern.exec(filename);
|
|
32
|
+
if (!match) {
|
|
34
33
|
return {filename, numberPrefix: undefined};
|
|
35
34
|
}
|
|
36
|
-
const match = NumberPrefixRegex.exec(filename);
|
|
37
|
-
const cleanFileName = match?.groups?.suffix ?? filename;
|
|
38
|
-
const numberPrefixString = match?.groups?.numberPrefix;
|
|
39
|
-
const numberPrefix = numberPrefixString
|
|
40
|
-
? parseInt(numberPrefixString, 10)
|
|
41
|
-
: undefined;
|
|
42
35
|
return {
|
|
43
|
-
filename:
|
|
44
|
-
numberPrefix,
|
|
36
|
+
filename: match.groups!.suffix!,
|
|
37
|
+
numberPrefix: parseInt(match.groups!.numberPrefix!, 10),
|
|
45
38
|
};
|
|
46
39
|
};
|
|
47
40
|
|
package/src/options.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
|
-
|
|
7
|
+
|
|
8
|
+
import type {PluginOptions, Options} from '@docusaurus/plugin-content-docs';
|
|
8
9
|
import {
|
|
9
10
|
Joi,
|
|
10
11
|
RemarkPluginsSchema,
|
|
@@ -12,10 +13,12 @@ import {
|
|
|
12
13
|
AdmonitionsSchema,
|
|
13
14
|
URISchema,
|
|
14
15
|
} from '@docusaurus/utils-validation';
|
|
15
|
-
import {
|
|
16
|
-
|
|
16
|
+
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
17
|
+
|
|
18
|
+
import type {OptionValidationContext} from '@docusaurus/types';
|
|
19
|
+
import logger from '@docusaurus/logger';
|
|
17
20
|
import admonitions from 'remark-admonitions';
|
|
18
|
-
import {DefaultSidebarItemsGenerator} from './
|
|
21
|
+
import {DefaultSidebarItemsGenerator} from './sidebars/generator';
|
|
19
22
|
import {
|
|
20
23
|
DefaultNumberPrefixParser,
|
|
21
24
|
DisabledNumberPrefixParser,
|
|
@@ -24,12 +27,16 @@ import {
|
|
|
24
27
|
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
25
28
|
path: 'docs', // Path to data on filesystem, relative to site dir.
|
|
26
29
|
routeBasePath: 'docs', // URL Route.
|
|
27
|
-
|
|
30
|
+
tagsBasePath: 'tags', // URL Tags Route.
|
|
28
31
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
|
32
|
+
exclude: GlobExcludeDefault,
|
|
29
33
|
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
|
30
34
|
numberPrefixParser: DefaultNumberPrefixParser,
|
|
31
35
|
docLayoutComponent: '@theme/DocPage',
|
|
32
36
|
docItemComponent: '@theme/DocItem',
|
|
37
|
+
docTagDocListComponent: '@theme/DocTagDocListPage',
|
|
38
|
+
docTagsListComponent: '@theme/DocTagsListPage',
|
|
39
|
+
docCategoryGeneratedIndexComponent: '@theme/DocCategoryGeneratedIndexPage',
|
|
33
40
|
remarkPlugins: [],
|
|
34
41
|
rehypePlugins: [],
|
|
35
42
|
beforeDefaultRemarkPlugins: [],
|
|
@@ -37,25 +44,30 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
|
37
44
|
showLastUpdateTime: false,
|
|
38
45
|
showLastUpdateAuthor: false,
|
|
39
46
|
admonitions: {},
|
|
40
|
-
excludeNextVersionDocs: false,
|
|
41
47
|
includeCurrentVersion: true,
|
|
42
48
|
disableVersioning: false,
|
|
43
49
|
lastVersion: undefined,
|
|
44
50
|
versions: {},
|
|
45
51
|
editCurrentVersion: false,
|
|
46
52
|
editLocalizedFiles: false,
|
|
53
|
+
sidebarCollapsible: true,
|
|
54
|
+
sidebarCollapsed: true,
|
|
55
|
+
breadcrumbs: true,
|
|
47
56
|
};
|
|
48
57
|
|
|
49
58
|
const VersionOptionsSchema = Joi.object({
|
|
50
59
|
path: Joi.string().allow('').optional(),
|
|
51
60
|
label: Joi.string().optional(),
|
|
61
|
+
banner: Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
|
|
62
|
+
badge: Joi.boolean().optional(),
|
|
63
|
+
className: Joi.string().optional(),
|
|
52
64
|
});
|
|
53
65
|
|
|
54
66
|
const VersionsOptionsSchema = Joi.object()
|
|
55
67
|
.pattern(Joi.string().required(), VersionOptionsSchema)
|
|
56
68
|
.default(DEFAULT_OPTIONS.versions);
|
|
57
69
|
|
|
58
|
-
|
|
70
|
+
const OptionsSchema = Joi.object<PluginOptions>({
|
|
59
71
|
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
|
60
72
|
editUrl: Joi.alternatives().try(URISchema, Joi.function()),
|
|
61
73
|
editCurrentVersion: Joi.boolean().default(DEFAULT_OPTIONS.editCurrentVersion),
|
|
@@ -64,8 +76,15 @@ export const OptionsSchema = Joi.object({
|
|
|
64
76
|
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
|
65
77
|
// .allow('') ""
|
|
66
78
|
.default(DEFAULT_OPTIONS.routeBasePath),
|
|
67
|
-
|
|
79
|
+
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
|
80
|
+
// @ts-expect-error: deprecated
|
|
81
|
+
homePageId: Joi.any().forbidden().messages({
|
|
82
|
+
'any.unknown':
|
|
83
|
+
'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
|
|
84
|
+
}),
|
|
85
|
+
|
|
68
86
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
87
|
+
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
|
69
88
|
sidebarPath: Joi.alternatives().try(
|
|
70
89
|
Joi.boolean().invalid(true),
|
|
71
90
|
Joi.string(),
|
|
@@ -73,6 +92,8 @@ export const OptionsSchema = Joi.object({
|
|
|
73
92
|
sidebarItemsGenerator: Joi.function().default(
|
|
74
93
|
() => DEFAULT_OPTIONS.sidebarItemsGenerator,
|
|
75
94
|
),
|
|
95
|
+
sidebarCollapsible: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsible),
|
|
96
|
+
sidebarCollapsed: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsed),
|
|
76
97
|
numberPrefixParser: Joi.alternatives()
|
|
77
98
|
.try(
|
|
78
99
|
Joi.function(),
|
|
@@ -86,6 +107,15 @@ export const OptionsSchema = Joi.object({
|
|
|
86
107
|
.default(() => DEFAULT_OPTIONS.numberPrefixParser),
|
|
87
108
|
docLayoutComponent: Joi.string().default(DEFAULT_OPTIONS.docLayoutComponent),
|
|
88
109
|
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
|
110
|
+
docTagsListComponent: Joi.string().default(
|
|
111
|
+
DEFAULT_OPTIONS.docTagsListComponent,
|
|
112
|
+
),
|
|
113
|
+
docTagDocListComponent: Joi.string().default(
|
|
114
|
+
DEFAULT_OPTIONS.docTagDocListComponent,
|
|
115
|
+
),
|
|
116
|
+
docCategoryGeneratedIndexComponent: Joi.string().default(
|
|
117
|
+
DEFAULT_OPTIONS.docCategoryGeneratedIndexComponent,
|
|
118
|
+
),
|
|
89
119
|
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
|
90
120
|
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
|
|
91
121
|
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
|
|
@@ -101,9 +131,6 @@ export const OptionsSchema = Joi.object({
|
|
|
101
131
|
showLastUpdateAuthor: Joi.bool().default(
|
|
102
132
|
DEFAULT_OPTIONS.showLastUpdateAuthor,
|
|
103
133
|
),
|
|
104
|
-
excludeNextVersionDocs: Joi.bool().default(
|
|
105
|
-
DEFAULT_OPTIONS.excludeNextVersionDocs,
|
|
106
|
-
),
|
|
107
134
|
includeCurrentVersion: Joi.bool().default(
|
|
108
135
|
DEFAULT_OPTIONS.includeCurrentVersion,
|
|
109
136
|
),
|
|
@@ -111,34 +138,35 @@ export const OptionsSchema = Joi.object({
|
|
|
111
138
|
disableVersioning: Joi.bool().default(DEFAULT_OPTIONS.disableVersioning),
|
|
112
139
|
lastVersion: Joi.string().optional(),
|
|
113
140
|
versions: VersionsOptionsSchema,
|
|
141
|
+
breadcrumbs: Joi.bool().default(DEFAULT_OPTIONS.breadcrumbs),
|
|
114
142
|
});
|
|
115
143
|
|
|
116
144
|
export function validateOptions({
|
|
117
145
|
validate,
|
|
118
|
-
options,
|
|
119
|
-
}: OptionValidationContext<PluginOptions>):
|
|
120
|
-
|
|
121
|
-
// "slug: /" is better because the home doc can be different across versions
|
|
122
|
-
if (options.homePageId) {
|
|
123
|
-
console.log(
|
|
124
|
-
chalk.red(
|
|
125
|
-
`The docs plugin option homePageId=${options.homePageId} is deprecated. To make a doc the "home", prefer frontmatter: "slug: /"`,
|
|
126
|
-
),
|
|
127
|
-
);
|
|
128
|
-
}
|
|
146
|
+
options: userOptions,
|
|
147
|
+
}: OptionValidationContext<Options, PluginOptions>): PluginOptions {
|
|
148
|
+
let options = userOptions;
|
|
129
149
|
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
150
|
+
if (options.sidebarCollapsible === false) {
|
|
151
|
+
// When sidebarCollapsible=false and sidebarCollapsed=undefined, we don't
|
|
152
|
+
// want to have the inconsistency warning. We let options.sidebarCollapsible
|
|
153
|
+
// become the default value for options.sidebarCollapsed
|
|
154
|
+
if (typeof options.sidebarCollapsed === 'undefined') {
|
|
155
|
+
options = {
|
|
156
|
+
...options,
|
|
157
|
+
sidebarCollapsed: false,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (options.sidebarCollapsed) {
|
|
161
|
+
logger.warn`The docs plugin config is inconsistent. It does not make sense to use code=${'sidebarCollapsible: false'} and code=${'sidebarCollapsed: true'} at the same time. code=${'sidebarCollapsed: true'} will be ignored.`;
|
|
162
|
+
options = {
|
|
163
|
+
...options,
|
|
164
|
+
sidebarCollapsed: false,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
139
167
|
}
|
|
140
168
|
|
|
141
|
-
const normalizedOptions = validate(OptionsSchema, options);
|
|
169
|
+
const normalizedOptions = validate(OptionsSchema, options) as PluginOptions;
|
|
142
170
|
|
|
143
171
|
if (normalizedOptions.admonitions) {
|
|
144
172
|
normalizedOptions.remarkPlugins = normalizedOptions.remarkPlugins.concat([
|
|
@@ -5,53 +5,178 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
declare module '@docusaurus/plugin-content-docs' {
|
|
9
|
+
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export interface Assets {
|
|
12
|
+
image?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type NumberPrefixParser = (filename: string) => {
|
|
16
|
+
filename: string;
|
|
17
|
+
numberPrefix?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type CategoryIndexMatcherParam = {
|
|
21
|
+
/** The file name, without extension */
|
|
22
|
+
fileName: string;
|
|
23
|
+
/**
|
|
24
|
+
* The list of directories, from lowest level to highest.
|
|
25
|
+
* If there's no dir name, directories is ['.']
|
|
26
|
+
*/
|
|
27
|
+
directories: string[];
|
|
28
|
+
/** The extension, with a leading dot */
|
|
29
|
+
extension: string;
|
|
30
|
+
};
|
|
31
|
+
export type CategoryIndexMatcher = (
|
|
32
|
+
param: CategoryIndexMatcherParam,
|
|
33
|
+
) => boolean;
|
|
34
|
+
|
|
35
|
+
export type EditUrlFunction = (editUrlParams: {
|
|
36
|
+
version: string;
|
|
37
|
+
versionDocsDirPath: string;
|
|
38
|
+
docPath: string;
|
|
39
|
+
permalink: string;
|
|
40
|
+
locale: string;
|
|
41
|
+
}) => string | undefined;
|
|
42
|
+
|
|
43
|
+
export type MetadataOptions = {
|
|
44
|
+
routeBasePath: string;
|
|
45
|
+
editUrl?: string | EditUrlFunction;
|
|
46
|
+
editCurrentVersion: boolean;
|
|
47
|
+
editLocalizedFiles: boolean;
|
|
48
|
+
showLastUpdateTime?: boolean;
|
|
49
|
+
showLastUpdateAuthor?: boolean;
|
|
50
|
+
numberPrefixParser: NumberPrefixParser;
|
|
51
|
+
breadcrumbs: boolean;
|
|
13
52
|
};
|
|
14
53
|
|
|
54
|
+
export type PathOptions = {
|
|
55
|
+
path: string;
|
|
56
|
+
sidebarPath?: string | false | undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// TODO support custom version banner?
|
|
60
|
+
// {type: "error", content: "html content"}
|
|
61
|
+
export type VersionBanner = 'unreleased' | 'unmaintained';
|
|
62
|
+
export type VersionOptions = {
|
|
63
|
+
path?: string;
|
|
64
|
+
label?: string;
|
|
65
|
+
banner?: 'none' | VersionBanner;
|
|
66
|
+
badge?: boolean;
|
|
67
|
+
className?: string;
|
|
68
|
+
};
|
|
69
|
+
export type VersionsOptions = {
|
|
70
|
+
lastVersion?: string;
|
|
71
|
+
versions: {[versionName: string]: VersionOptions};
|
|
72
|
+
onlyIncludeVersions?: string[];
|
|
73
|
+
};
|
|
74
|
+
export type SidebarOptions = {
|
|
75
|
+
sidebarCollapsible: boolean;
|
|
76
|
+
sidebarCollapsed: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type PluginOptions = MetadataOptions &
|
|
80
|
+
PathOptions &
|
|
81
|
+
VersionsOptions &
|
|
82
|
+
RemarkAndRehypePluginOptions &
|
|
83
|
+
SidebarOptions & {
|
|
84
|
+
id: string;
|
|
85
|
+
include: string[];
|
|
86
|
+
exclude: string[];
|
|
87
|
+
docLayoutComponent: string;
|
|
88
|
+
docItemComponent: string;
|
|
89
|
+
docTagDocListComponent: string;
|
|
90
|
+
docTagsListComponent: string;
|
|
91
|
+
docCategoryGeneratedIndexComponent: string;
|
|
92
|
+
admonitions: {[key: string]: unknown};
|
|
93
|
+
disableVersioning: boolean;
|
|
94
|
+
includeCurrentVersion: boolean;
|
|
95
|
+
sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
|
|
96
|
+
tagsBasePath: string;
|
|
97
|
+
};
|
|
98
|
+
export type Options = Partial<PluginOptions>;
|
|
99
|
+
export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
|
|
100
|
+
|
|
101
|
+
export type PropNavigationLink = {
|
|
102
|
+
readonly title: string;
|
|
103
|
+
readonly permalink: string;
|
|
104
|
+
};
|
|
105
|
+
export type PropNavigation = {
|
|
106
|
+
readonly previous?: PropNavigationLink;
|
|
107
|
+
readonly next?: PropNavigationLink;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type PropVersionDoc = import('./sidebars/types').PropVersionDoc;
|
|
111
|
+
export type PropVersionDocs = import('./sidebars/types').PropVersionDocs;
|
|
112
|
+
|
|
15
113
|
export type PropVersionMetadata = {
|
|
16
114
|
pluginId: string;
|
|
17
115
|
version: string;
|
|
18
116
|
label: string;
|
|
117
|
+
banner: VersionBanner | null;
|
|
118
|
+
badge: boolean;
|
|
119
|
+
className: string;
|
|
19
120
|
isLast: boolean;
|
|
20
121
|
docsSidebars: PropSidebars;
|
|
21
|
-
|
|
122
|
+
docs: PropVersionDocs;
|
|
22
123
|
};
|
|
23
124
|
|
|
24
|
-
type
|
|
25
|
-
|
|
125
|
+
export type PropCategoryGeneratedIndex = {
|
|
126
|
+
title: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
image?: string;
|
|
129
|
+
keywords?: string | readonly string[];
|
|
130
|
+
slug: string;
|
|
131
|
+
permalink: string;
|
|
132
|
+
navigation: PropNavigation;
|
|
26
133
|
};
|
|
27
134
|
|
|
28
|
-
export type PropSidebarItemLink =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
135
|
+
export type PropSidebarItemLink =
|
|
136
|
+
import('./sidebars/types').PropSidebarItemLink;
|
|
137
|
+
export type PropSidebarItemCategory =
|
|
138
|
+
import('./sidebars/types').PropSidebarItemCategory;
|
|
139
|
+
export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
|
|
140
|
+
export type PropSidebarBreadcrumbsItem =
|
|
141
|
+
import('./sidebars/types').PropSidebarBreadcrumbsItem;
|
|
142
|
+
export type PropSidebar = import('./sidebars/types').PropSidebar;
|
|
143
|
+
export type PropSidebars = import('./sidebars/types').PropSidebars;
|
|
33
144
|
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
145
|
+
export type PropTagDocListDoc = {
|
|
146
|
+
id: string;
|
|
147
|
+
title: string;
|
|
148
|
+
description: string;
|
|
149
|
+
permalink: string;
|
|
150
|
+
};
|
|
151
|
+
export type PropTagDocList = {
|
|
152
|
+
allTagsPath: string;
|
|
153
|
+
name: string; // normalized name/label of the tag
|
|
154
|
+
permalink: string; // pathname of the tag
|
|
155
|
+
docs: PropTagDocListDoc[];
|
|
39
156
|
};
|
|
40
157
|
|
|
41
|
-
export type
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
158
|
+
export type PropTagsListPage = {
|
|
159
|
+
tags: {
|
|
160
|
+
name: string;
|
|
161
|
+
permalink: string;
|
|
162
|
+
count: number;
|
|
163
|
+
}[];
|
|
45
164
|
};
|
|
46
165
|
}
|
|
47
166
|
|
|
48
167
|
declare module '@theme/DocItem' {
|
|
49
168
|
import type {TOCItem} from '@docusaurus/types';
|
|
169
|
+
import type {
|
|
170
|
+
PropNavigationLink,
|
|
171
|
+
PropVersionMetadata,
|
|
172
|
+
Assets,
|
|
173
|
+
} from '@docusaurus/plugin-content-docs';
|
|
50
174
|
|
|
51
175
|
export type DocumentRoute = {
|
|
52
176
|
readonly component: () => JSX.Element;
|
|
53
177
|
readonly exact: boolean;
|
|
54
178
|
readonly path: string;
|
|
179
|
+
readonly sidebar?: string;
|
|
55
180
|
};
|
|
56
181
|
|
|
57
182
|
export type FrontMatter = {
|
|
@@ -61,9 +186,12 @@ declare module '@theme/DocItem' {
|
|
|
61
186
|
readonly keywords?: readonly string[];
|
|
62
187
|
readonly hide_title?: boolean;
|
|
63
188
|
readonly hide_table_of_contents?: boolean;
|
|
189
|
+
readonly toc_min_heading_level?: number;
|
|
190
|
+
readonly toc_max_heading_level?: number;
|
|
64
191
|
};
|
|
65
192
|
|
|
66
193
|
export type Metadata = {
|
|
194
|
+
readonly unversionedId?: string;
|
|
67
195
|
readonly description?: string;
|
|
68
196
|
readonly title?: string;
|
|
69
197
|
readonly permalink?: string;
|
|
@@ -72,29 +200,67 @@ declare module '@theme/DocItem' {
|
|
|
72
200
|
readonly formattedLastUpdatedAt?: string;
|
|
73
201
|
readonly lastUpdatedBy?: string;
|
|
74
202
|
readonly version?: string;
|
|
75
|
-
readonly previous?:
|
|
76
|
-
readonly next?:
|
|
203
|
+
readonly previous?: PropNavigationLink;
|
|
204
|
+
readonly next?: PropNavigationLink;
|
|
205
|
+
readonly tags: readonly {
|
|
206
|
+
readonly label: string;
|
|
207
|
+
readonly permalink: string;
|
|
208
|
+
}[];
|
|
77
209
|
};
|
|
78
210
|
|
|
79
|
-
export
|
|
211
|
+
export interface Props {
|
|
80
212
|
readonly route: DocumentRoute;
|
|
213
|
+
readonly versionMetadata: PropVersionMetadata;
|
|
81
214
|
readonly content: {
|
|
82
215
|
readonly frontMatter: FrontMatter;
|
|
83
216
|
readonly metadata: Metadata;
|
|
84
217
|
readonly toc: readonly TOCItem[];
|
|
218
|
+
readonly contentTitle: string | undefined;
|
|
219
|
+
readonly assets: Assets;
|
|
85
220
|
(): JSX.Element;
|
|
86
221
|
};
|
|
87
|
-
}
|
|
222
|
+
}
|
|
88
223
|
|
|
89
|
-
|
|
90
|
-
|
|
224
|
+
export default function DocItem(props: Props): JSX.Element;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare module '@theme/DocCategoryGeneratedIndexPage' {
|
|
228
|
+
import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
|
|
229
|
+
|
|
230
|
+
export interface Props {
|
|
231
|
+
readonly categoryGeneratedIndex: PropCategoryGeneratedIndex;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export default function DocCategoryGeneratedIndexPage(
|
|
235
|
+
props: Props,
|
|
236
|
+
): JSX.Element;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare module '@theme/DocTagsListPage' {
|
|
240
|
+
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
|
|
241
|
+
|
|
242
|
+
export interface Props extends PropTagsListPage {}
|
|
243
|
+
export default function DocTagsListPage(props: Props): JSX.Element;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare module '@theme/DocTagDocListPage' {
|
|
247
|
+
import type {PropTagDocList} from '@docusaurus/plugin-content-docs';
|
|
248
|
+
|
|
249
|
+
export interface Props {
|
|
250
|
+
readonly tag: PropTagDocList;
|
|
251
|
+
}
|
|
252
|
+
export default function DocTagDocListPage(props: Props): JSX.Element;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare module '@theme/DocBreadcrumbs' {
|
|
256
|
+
export default function DocBreadcrumbs(): JSX.Element;
|
|
91
257
|
}
|
|
92
258
|
|
|
93
259
|
declare module '@theme/DocPage' {
|
|
94
|
-
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs
|
|
260
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
95
261
|
import type {DocumentRoute} from '@theme/DocItem';
|
|
96
262
|
|
|
97
|
-
export
|
|
263
|
+
export interface Props {
|
|
98
264
|
readonly location: {readonly pathname: string};
|
|
99
265
|
readonly versionMetadata: PropVersionMetadata;
|
|
100
266
|
readonly route: {
|
|
@@ -102,20 +268,77 @@ declare module '@theme/DocPage' {
|
|
|
102
268
|
readonly component: () => JSX.Element;
|
|
103
269
|
readonly routes: DocumentRoute[];
|
|
104
270
|
};
|
|
105
|
-
}
|
|
271
|
+
}
|
|
106
272
|
|
|
107
|
-
|
|
108
|
-
export default DocPage;
|
|
273
|
+
export default function DocPage(props: Props): JSX.Element;
|
|
109
274
|
}
|
|
110
275
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
276
|
+
// TODO until TS supports exports field... hope it's in 4.6
|
|
277
|
+
declare module '@docusaurus/plugin-content-docs/client' {
|
|
278
|
+
export type ActivePlugin = {
|
|
279
|
+
pluginId: string;
|
|
280
|
+
pluginData: GlobalPluginData;
|
|
281
|
+
};
|
|
282
|
+
export type ActiveDocContext = {
|
|
283
|
+
activeVersion?: GlobalVersion;
|
|
284
|
+
activeDoc?: GlobalDoc;
|
|
285
|
+
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
286
|
+
};
|
|
287
|
+
export type GlobalDoc = {
|
|
288
|
+
id: string;
|
|
289
|
+
path: string;
|
|
290
|
+
sidebar: string | undefined;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export type GlobalVersion = {
|
|
294
|
+
name: string;
|
|
295
|
+
label: string;
|
|
296
|
+
isLast: boolean;
|
|
297
|
+
path: string;
|
|
298
|
+
mainDocId: string; // home doc (if docs homepage configured), or first doc
|
|
299
|
+
docs: GlobalDoc[];
|
|
300
|
+
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export type GlobalSidebarLink = {
|
|
304
|
+
label: string;
|
|
305
|
+
path: string;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export type GlobalSidebar = {
|
|
309
|
+
link?: GlobalSidebarLink;
|
|
310
|
+
// ... we may add other things here later
|
|
311
|
+
};
|
|
312
|
+
export type GlobalPluginData = {
|
|
313
|
+
path: string;
|
|
314
|
+
versions: GlobalVersion[];
|
|
315
|
+
breadcrumbs: boolean;
|
|
316
|
+
};
|
|
317
|
+
export type DocVersionSuggestions = {
|
|
318
|
+
// suggest the latest version
|
|
319
|
+
latestVersionSuggestion: GlobalVersion;
|
|
320
|
+
// suggest the same doc, in latest version (if exist)
|
|
321
|
+
latestDocSuggestion?: GlobalDoc;
|
|
117
322
|
};
|
|
323
|
+
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
|
|
118
324
|
|
|
119
|
-
const
|
|
120
|
-
export
|
|
325
|
+
export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
|
|
326
|
+
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
327
|
+
export const useActivePlugin: (
|
|
328
|
+
options?: GetActivePluginOptions,
|
|
329
|
+
) => ActivePlugin | undefined;
|
|
330
|
+
export const useActivePluginAndVersion: (
|
|
331
|
+
options?: GetActivePluginOptions,
|
|
332
|
+
) =>
|
|
333
|
+
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
334
|
+
| undefined;
|
|
335
|
+
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
336
|
+
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
337
|
+
export const useActiveVersion: (
|
|
338
|
+
pluginId?: string,
|
|
339
|
+
) => GlobalVersion | undefined;
|
|
340
|
+
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
341
|
+
export const useDocVersionSuggestions: (
|
|
342
|
+
pluginId?: string,
|
|
343
|
+
) => DocVersionSuggestions;
|
|
121
344
|
}
|