@docusaurus/plugin-content-docs 2.0.0-beta.8bda3b2db → 2.0.0-beta.9
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/.tsbuildinfo +1 -1
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +20 -24
- package/lib/client/docsClientUtils.d.ts +1 -4
- package/lib/client/docsClientUtils.js +12 -16
- package/lib/docFrontMatter.js +7 -3
- package/lib/docs.d.ts +4 -2
- package/lib/docs.js +77 -23
- package/lib/index.js +88 -94
- package/lib/lastUpdate.js +8 -8
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.js +2 -2
- package/lib/options.d.ts +1 -1
- package/lib/options.js +39 -11
- package/lib/props.d.ts +7 -2
- package/lib/props.js +27 -4
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +3 -1
- package/lib/sidebars/generator.js +174 -0
- package/lib/sidebars/index.d.ts +14 -0
- package/lib/sidebars/index.js +64 -0
- package/lib/sidebars/normalization.d.ts +9 -0
- package/lib/sidebars/normalization.js +58 -0
- package/lib/sidebars/processor.d.ts +16 -0
- package/lib/sidebars/processor.js +70 -0
- package/lib/sidebars/types.d.ts +87 -0
- package/lib/sidebars/types.js +13 -0
- package/lib/sidebars/utils.d.ts +22 -0
- package/lib/sidebars/utils.js +101 -0
- package/lib/sidebars/validation.d.ts +8 -0
- package/lib/sidebars/validation.js +102 -0
- package/lib/slug.js +4 -4
- package/lib/tags.d.ts +8 -0
- package/lib/tags.js +22 -0
- package/lib/theme/hooks/useDocs.js +24 -21
- package/lib/translations.d.ts +1 -1
- package/lib/translations.js +13 -13
- package/lib/types.d.ts +35 -58
- package/lib/versions.d.ts +1 -1
- package/lib/versions.js +75 -22
- package/package.json +15 -14
- package/src/__tests__/__fixtures__/simple-site/docs/_partials/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/_partials/subfolder/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/_somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +5 -0
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +1 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/sidebars.json +15 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +6 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/subfolder/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_somePartial.md +3 -0
- package/src/__tests__/__snapshots__/cli.test.ts.snap +33 -0
- package/src/__tests__/__snapshots__/docs.test.ts.snap +140 -0
- package/src/__tests__/__snapshots__/index.test.ts.snap +478 -60
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -3
- package/src/__tests__/cli.test.ts +14 -10
- package/src/__tests__/docFrontMatter.test.ts +163 -48
- package/src/__tests__/docs.test.ts +167 -21
- package/src/__tests__/index.test.ts +74 -30
- package/src/__tests__/lastUpdate.test.ts +3 -2
- package/src/__tests__/options.test.ts +46 -3
- package/src/__tests__/props.test.ts +62 -0
- package/src/__tests__/translations.test.ts +0 -1
- package/src/__tests__/versions.test.ts +88 -60
- package/src/cli.ts +27 -30
- package/src/client/__tests__/docsClientUtils.test.ts +4 -5
- package/src/client/docsClientUtils.ts +6 -27
- package/src/docFrontMatter.ts +8 -3
- package/src/docs.ts +92 -9
- package/src/index.ts +114 -121
- package/src/lastUpdate.ts +10 -6
- package/src/markdown/index.ts +8 -12
- package/src/numberPrefix.ts +4 -2
- package/src/options.ts +47 -17
- package/src/plugin-content-docs.d.ts +121 -34
- package/src/props.ts +42 -6
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-collapsed.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-unknown-type.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-wrong-field.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars.json +0 -0
- package/src/{__tests__/__snapshots__/sidebars.test.ts.snap → sidebars/__tests__/__snapshots__/index.test.ts.snap} +21 -6
- package/src/{__tests__/sidebarItemsGenerator.test.ts → sidebars/__tests__/generator.test.ts} +29 -7
- package/src/sidebars/__tests__/index.test.ts +202 -0
- package/src/sidebars/__tests__/processor.test.ts +148 -0
- package/src/sidebars/__tests__/utils.test.ts +395 -0
- package/src/sidebars/generator.ts +253 -0
- package/src/sidebars/index.ts +84 -0
- package/src/sidebars/normalization.ts +88 -0
- package/src/sidebars/processor.ts +124 -0
- package/src/sidebars/types.ts +156 -0
- package/src/sidebars/utils.ts +146 -0
- package/src/sidebars/validation.ts +124 -0
- package/src/tags.ts +21 -0
- package/src/theme/hooks/useDocs.ts +5 -1
- package/src/translations.ts +26 -36
- package/src/types.ts +48 -99
- package/src/versions.ts +109 -17
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -43
- package/lib/sidebars.js +0 -319
- package/src/__tests__/sidebars.test.ts +0 -639
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -506
package/src/options.ts
CHANGED
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
AdmonitionsSchema,
|
|
13
13
|
URISchema,
|
|
14
14
|
} from '@docusaurus/utils-validation';
|
|
15
|
+
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
16
|
+
|
|
15
17
|
import {OptionValidationContext, ValidationResult} from '@docusaurus/types';
|
|
16
18
|
import chalk from 'chalk';
|
|
17
19
|
import admonitions from 'remark-admonitions';
|
|
18
|
-
import {DefaultSidebarItemsGenerator} from './
|
|
20
|
+
import {DefaultSidebarItemsGenerator} from './sidebars/generator';
|
|
19
21
|
import {
|
|
20
22
|
DefaultNumberPrefixParser,
|
|
21
23
|
DisabledNumberPrefixParser,
|
|
@@ -24,12 +26,16 @@ import {
|
|
|
24
26
|
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
25
27
|
path: 'docs', // Path to data on filesystem, relative to site dir.
|
|
26
28
|
routeBasePath: 'docs', // URL Route.
|
|
29
|
+
tagsBasePath: 'tags', // URL Tags Route.
|
|
27
30
|
homePageId: undefined, // TODO remove soon, deprecated
|
|
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',
|
|
33
39
|
remarkPlugins: [],
|
|
34
40
|
rehypePlugins: [],
|
|
35
41
|
beforeDefaultRemarkPlugins: [],
|
|
@@ -37,18 +43,22 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
|
37
43
|
showLastUpdateTime: false,
|
|
38
44
|
showLastUpdateAuthor: false,
|
|
39
45
|
admonitions: {},
|
|
40
|
-
excludeNextVersionDocs: false,
|
|
41
46
|
includeCurrentVersion: true,
|
|
42
47
|
disableVersioning: false,
|
|
43
48
|
lastVersion: undefined,
|
|
44
49
|
versions: {},
|
|
45
50
|
editCurrentVersion: false,
|
|
46
51
|
editLocalizedFiles: false,
|
|
52
|
+
sidebarCollapsible: true,
|
|
53
|
+
sidebarCollapsed: true,
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
const VersionOptionsSchema = Joi.object({
|
|
50
57
|
path: Joi.string().allow('').optional(),
|
|
51
58
|
label: Joi.string().optional(),
|
|
59
|
+
banner: Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
|
|
60
|
+
badge: Joi.boolean().optional(),
|
|
61
|
+
className: Joi.string().optional(),
|
|
52
62
|
});
|
|
53
63
|
|
|
54
64
|
const VersionsOptionsSchema = Joi.object()
|
|
@@ -64,8 +74,10 @@ export const OptionsSchema = Joi.object({
|
|
|
64
74
|
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
|
65
75
|
// .allow('') ""
|
|
66
76
|
.default(DEFAULT_OPTIONS.routeBasePath),
|
|
77
|
+
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
|
67
78
|
homePageId: Joi.string().optional(),
|
|
68
79
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
80
|
+
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
|
69
81
|
sidebarPath: Joi.alternatives().try(
|
|
70
82
|
Joi.boolean().invalid(true),
|
|
71
83
|
Joi.string(),
|
|
@@ -73,6 +85,8 @@ export const OptionsSchema = Joi.object({
|
|
|
73
85
|
sidebarItemsGenerator: Joi.function().default(
|
|
74
86
|
() => DEFAULT_OPTIONS.sidebarItemsGenerator,
|
|
75
87
|
),
|
|
88
|
+
sidebarCollapsible: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsible),
|
|
89
|
+
sidebarCollapsed: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsed),
|
|
76
90
|
numberPrefixParser: Joi.alternatives()
|
|
77
91
|
.try(
|
|
78
92
|
Joi.function(),
|
|
@@ -86,6 +100,12 @@ export const OptionsSchema = Joi.object({
|
|
|
86
100
|
.default(() => DEFAULT_OPTIONS.numberPrefixParser),
|
|
87
101
|
docLayoutComponent: Joi.string().default(DEFAULT_OPTIONS.docLayoutComponent),
|
|
88
102
|
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
|
103
|
+
docTagsListComponent: Joi.string().default(
|
|
104
|
+
DEFAULT_OPTIONS.docTagsListComponent,
|
|
105
|
+
),
|
|
106
|
+
docTagDocListComponent: Joi.string().default(
|
|
107
|
+
DEFAULT_OPTIONS.docTagDocListComponent,
|
|
108
|
+
),
|
|
89
109
|
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
|
90
110
|
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
|
|
91
111
|
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
|
|
@@ -101,9 +121,6 @@ export const OptionsSchema = Joi.object({
|
|
|
101
121
|
showLastUpdateAuthor: Joi.bool().default(
|
|
102
122
|
DEFAULT_OPTIONS.showLastUpdateAuthor,
|
|
103
123
|
),
|
|
104
|
-
excludeNextVersionDocs: Joi.bool().default(
|
|
105
|
-
DEFAULT_OPTIONS.excludeNextVersionDocs,
|
|
106
|
-
),
|
|
107
124
|
includeCurrentVersion: Joi.bool().default(
|
|
108
125
|
DEFAULT_OPTIONS.includeCurrentVersion,
|
|
109
126
|
),
|
|
@@ -115,8 +132,32 @@ export const OptionsSchema = Joi.object({
|
|
|
115
132
|
|
|
116
133
|
export function validateOptions({
|
|
117
134
|
validate,
|
|
118
|
-
options,
|
|
135
|
+
options: userOptions,
|
|
119
136
|
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
|
|
137
|
+
let options = userOptions;
|
|
138
|
+
|
|
139
|
+
if (options.sidebarCollapsible === false) {
|
|
140
|
+
// When sidebarCollapsible=false and sidebarCollapsed=undefined, we don't want to have the inconsistency warning
|
|
141
|
+
// We let options.sidebarCollapsible become the default value for options.sidebarCollapsed
|
|
142
|
+
if (typeof options.sidebarCollapsed === 'undefined') {
|
|
143
|
+
options = {
|
|
144
|
+
...options,
|
|
145
|
+
sidebarCollapsed: false,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (options.sidebarCollapsed) {
|
|
149
|
+
console.warn(
|
|
150
|
+
chalk.yellow(
|
|
151
|
+
'The docs plugin config is inconsistent. It does not make sense to use sidebarCollapsible=false and sidebarCollapsed=true at the same time. sidebarCollapsed=false will be ignored.',
|
|
152
|
+
),
|
|
153
|
+
);
|
|
154
|
+
options = {
|
|
155
|
+
...options,
|
|
156
|
+
sidebarCollapsed: false,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
120
161
|
// TODO remove homePageId before end of 2020
|
|
121
162
|
// "slug: /" is better because the home doc can be different across versions
|
|
122
163
|
if (options.homePageId) {
|
|
@@ -127,17 +168,6 @@ export function validateOptions({
|
|
|
127
168
|
);
|
|
128
169
|
}
|
|
129
170
|
|
|
130
|
-
if (typeof options.excludeNextVersionDocs !== 'undefined') {
|
|
131
|
-
console.log(
|
|
132
|
-
chalk.red(
|
|
133
|
-
`The docs plugin option "excludeNextVersionDocs=${
|
|
134
|
-
options.excludeNextVersionDocs
|
|
135
|
-
}" is deprecated. Use the "includeCurrentVersion=${!options.excludeNextVersionDocs}" option instead!"`,
|
|
136
|
-
),
|
|
137
|
-
);
|
|
138
|
-
options.includeCurrentVersion = !options.excludeNextVersionDocs;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
171
|
const normalizedOptions = validate(OptionsSchema, options);
|
|
142
172
|
|
|
143
173
|
if (normalizedOptions.admonitions) {
|
|
@@ -5,58 +5,68 @@
|
|
|
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
|
+
export type Options = Partial<import('./types').PluginOptions>;
|
|
10
|
+
export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
|
|
11
|
+
}
|
|
9
12
|
|
|
13
|
+
// TODO public api surface types should rather be exposed as "@docusaurus/plugin-content-docs"
|
|
10
14
|
declare module '@docusaurus/plugin-content-docs-types' {
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
export type VersionBanner = import('./types').VersionBanner;
|
|
16
|
+
type GlobalDataVersion = import('./types').GlobalVersion;
|
|
17
|
+
type GlobalDataDoc = import('./types').GlobalDoc;
|
|
18
|
+
type VersionTag = import('./types').VersionTag;
|
|
19
|
+
|
|
20
|
+
export type {GlobalDataVersion, GlobalDataDoc};
|
|
14
21
|
|
|
15
22
|
export type PropVersionMetadata = {
|
|
16
23
|
pluginId: string;
|
|
17
24
|
version: string;
|
|
18
25
|
label: string;
|
|
26
|
+
banner: VersionBanner | null;
|
|
27
|
+
badge: boolean;
|
|
28
|
+
className: string;
|
|
19
29
|
isLast: boolean;
|
|
20
30
|
docsSidebars: PropSidebars;
|
|
21
|
-
permalinkToSidebar: PermalinkToSidebar;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
|
-
type
|
|
25
|
-
|
|
33
|
+
export type PropSidebarItemLink = import('./sidebars/types').SidebarItemLink;
|
|
34
|
+
export type PropSidebarItemCategory =
|
|
35
|
+
import('./sidebars/types').PropSidebarItemCategory;
|
|
36
|
+
export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
|
|
37
|
+
export type PropSidebars = import('./sidebars/types').PropSidebars;
|
|
38
|
+
|
|
39
|
+
export type PropTagDocListDoc = {
|
|
40
|
+
id: string;
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
permalink: string;
|
|
26
44
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
export type PropTagDocList = {
|
|
46
|
+
allTagsPath: string;
|
|
47
|
+
name: string; // normalized name/label of the tag
|
|
48
|
+
permalink: string; // pathname of the tag
|
|
49
|
+
docs: PropTagDocListDoc[];
|
|
32
50
|
};
|
|
33
51
|
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory;
|
|
42
|
-
|
|
43
|
-
export type PropSidebars = {
|
|
44
|
-
[sidebarId: string]: PropSidebarItem[];
|
|
52
|
+
export type PropTagsListPage = {
|
|
53
|
+
tags: {
|
|
54
|
+
name: string;
|
|
55
|
+
permalink: string;
|
|
56
|
+
count: number;
|
|
57
|
+
}[];
|
|
45
58
|
};
|
|
46
|
-
|
|
47
|
-
export type {
|
|
48
|
-
GlobalVersion as GlobalDataVersion,
|
|
49
|
-
GlobalDoc as GlobalDataDoc,
|
|
50
|
-
} from './types';
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
declare module '@theme/DocItem' {
|
|
54
62
|
import type {TOCItem} from '@docusaurus/types';
|
|
63
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
|
|
55
64
|
|
|
56
65
|
export type DocumentRoute = {
|
|
57
66
|
readonly component: () => JSX.Element;
|
|
58
67
|
readonly exact: boolean;
|
|
59
68
|
readonly path: string;
|
|
69
|
+
readonly sidebar?: string;
|
|
60
70
|
};
|
|
61
71
|
|
|
62
72
|
export type FrontMatter = {
|
|
@@ -64,8 +74,12 @@ declare module '@theme/DocItem' {
|
|
|
64
74
|
readonly title: string;
|
|
65
75
|
readonly image?: string;
|
|
66
76
|
readonly keywords?: readonly string[];
|
|
77
|
+
/* eslint-disable camelcase */
|
|
67
78
|
readonly hide_title?: boolean;
|
|
68
79
|
readonly hide_table_of_contents?: boolean;
|
|
80
|
+
readonly toc_min_heading_level?: number;
|
|
81
|
+
readonly toc_max_heading_level?: number;
|
|
82
|
+
/* eslint-enable camelcase */
|
|
69
83
|
};
|
|
70
84
|
|
|
71
85
|
export type Metadata = {
|
|
@@ -79,10 +93,15 @@ declare module '@theme/DocItem' {
|
|
|
79
93
|
readonly version?: string;
|
|
80
94
|
readonly previous?: {readonly permalink: string; readonly title: string};
|
|
81
95
|
readonly next?: {readonly permalink: string; readonly title: string};
|
|
96
|
+
readonly tags: readonly {
|
|
97
|
+
readonly label: string;
|
|
98
|
+
readonly permalink: string;
|
|
99
|
+
}[];
|
|
82
100
|
};
|
|
83
101
|
|
|
84
|
-
export
|
|
102
|
+
export interface Props {
|
|
85
103
|
readonly route: DocumentRoute;
|
|
104
|
+
readonly versionMetadata: PropVersionMetadata;
|
|
86
105
|
readonly content: {
|
|
87
106
|
readonly frontMatter: FrontMatter;
|
|
88
107
|
readonly metadata: Metadata;
|
|
@@ -90,17 +109,50 @@ declare module '@theme/DocItem' {
|
|
|
90
109
|
readonly contentTitle: string | undefined;
|
|
91
110
|
(): JSX.Element;
|
|
92
111
|
};
|
|
93
|
-
}
|
|
112
|
+
}
|
|
94
113
|
|
|
95
114
|
const DocItem: (props: Props) => JSX.Element;
|
|
96
115
|
export default DocItem;
|
|
97
116
|
}
|
|
98
117
|
|
|
118
|
+
declare module '@theme/DocItemFooter' {
|
|
119
|
+
import type {Props} from '@theme/DocItem';
|
|
120
|
+
|
|
121
|
+
export default function DocItemFooter(props: Props): JSX.Element;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare module '@theme/DocTagsListPage' {
|
|
125
|
+
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs-types';
|
|
126
|
+
|
|
127
|
+
export interface Props extends PropTagsListPage {}
|
|
128
|
+
export default function DocTagsListPage(props: Props): JSX.Element;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare module '@theme/DocTagDocListPage' {
|
|
132
|
+
import type {PropTagDocList} from '@docusaurus/plugin-content-docs-types';
|
|
133
|
+
|
|
134
|
+
export interface Props {
|
|
135
|
+
readonly tag: PropTagDocList;
|
|
136
|
+
}
|
|
137
|
+
export default function DocTagDocListPage(props: Props): JSX.Element;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare module '@theme/DocVersionBanner' {
|
|
141
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
|
|
142
|
+
|
|
143
|
+
export interface Props {
|
|
144
|
+
readonly versionMetadata: PropVersionMetadata;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const DocVersionBanner: (props: Props) => JSX.Element;
|
|
148
|
+
export default DocVersionBanner;
|
|
149
|
+
}
|
|
150
|
+
|
|
99
151
|
declare module '@theme/DocPage' {
|
|
100
152
|
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
|
|
101
153
|
import type {DocumentRoute} from '@theme/DocItem';
|
|
102
154
|
|
|
103
|
-
export
|
|
155
|
+
export interface Props {
|
|
104
156
|
readonly location: {readonly pathname: string};
|
|
105
157
|
readonly versionMetadata: PropVersionMetadata;
|
|
106
158
|
readonly route: {
|
|
@@ -108,20 +160,55 @@ declare module '@theme/DocPage' {
|
|
|
108
160
|
readonly component: () => JSX.Element;
|
|
109
161
|
readonly routes: DocumentRoute[];
|
|
110
162
|
};
|
|
111
|
-
}
|
|
163
|
+
}
|
|
112
164
|
|
|
113
165
|
const DocPage: (props: Props) => JSX.Element;
|
|
114
166
|
export default DocPage;
|
|
115
167
|
}
|
|
116
168
|
|
|
117
169
|
declare module '@theme/Seo' {
|
|
118
|
-
|
|
170
|
+
import type {ReactNode} from 'react';
|
|
171
|
+
|
|
172
|
+
export interface Props {
|
|
119
173
|
readonly title?: string;
|
|
120
174
|
readonly description?: string;
|
|
121
175
|
readonly keywords?: readonly string[] | string;
|
|
122
176
|
readonly image?: string;
|
|
123
|
-
|
|
177
|
+
readonly children?: ReactNode;
|
|
178
|
+
}
|
|
124
179
|
|
|
125
180
|
const Seo: (props: Props) => JSX.Element;
|
|
126
181
|
export default Seo;
|
|
127
182
|
}
|
|
183
|
+
|
|
184
|
+
declare module '@theme/hooks/useDocs' {
|
|
185
|
+
type GlobalPluginData = import('./types').GlobalPluginData;
|
|
186
|
+
type GlobalVersion = import('./types').GlobalVersion;
|
|
187
|
+
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
|
188
|
+
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
|
|
189
|
+
type DocVersionSuggestions =
|
|
190
|
+
import('./client/docsClientUtils').DocVersionSuggestions;
|
|
191
|
+
type GetActivePluginOptions =
|
|
192
|
+
import('./client/docsClientUtils').GetActivePluginOptions;
|
|
193
|
+
|
|
194
|
+
export type {GlobalPluginData, GlobalVersion};
|
|
195
|
+
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
|
196
|
+
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
197
|
+
export const useActivePlugin: (
|
|
198
|
+
options?: GetActivePluginOptions,
|
|
199
|
+
) => ActivePlugin | undefined;
|
|
200
|
+
export const useActivePluginAndVersion: (
|
|
201
|
+
options?: GetActivePluginOptions,
|
|
202
|
+
) =>
|
|
203
|
+
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
204
|
+
| undefined;
|
|
205
|
+
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
206
|
+
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
207
|
+
export const useActiveVersion: (
|
|
208
|
+
pluginId?: string,
|
|
209
|
+
) => GlobalVersion | undefined;
|
|
210
|
+
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
211
|
+
export const useDocVersionSuggestions: (
|
|
212
|
+
pluginId?: string,
|
|
213
|
+
) => DocVersionSuggestions;
|
|
214
|
+
}
|
package/src/props.ts
CHANGED
|
@@ -5,18 +5,20 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {LoadedVersion, VersionTag, DocMetadata} from './types';
|
|
9
|
+
import type {
|
|
10
10
|
SidebarItemDoc,
|
|
11
11
|
SidebarItemLink,
|
|
12
12
|
SidebarItem,
|
|
13
|
-
} from './types';
|
|
14
|
-
import {
|
|
13
|
+
} from './sidebars/types';
|
|
14
|
+
import type {
|
|
15
15
|
PropSidebars,
|
|
16
16
|
PropVersionMetadata,
|
|
17
17
|
PropSidebarItem,
|
|
18
|
+
PropTagDocList,
|
|
19
|
+
PropTagDocListDoc,
|
|
18
20
|
} from '@docusaurus/plugin-content-docs-types';
|
|
19
|
-
import {keyBy, mapValues} from 'lodash';
|
|
21
|
+
import {compact, keyBy, mapValues} from 'lodash';
|
|
20
22
|
|
|
21
23
|
export function toSidebarsProp(loadedVersion: LoadedVersion): PropSidebars {
|
|
22
24
|
const docsById = keyBy(loadedVersion.docs, (doc) => doc.id);
|
|
@@ -43,6 +45,7 @@ Available document ids are:
|
|
|
43
45
|
type: 'link',
|
|
44
46
|
label: sidebarLabel || item.label || title,
|
|
45
47
|
href: permalink,
|
|
48
|
+
className: item.className,
|
|
46
49
|
customProps: item.customProps,
|
|
47
50
|
};
|
|
48
51
|
};
|
|
@@ -74,8 +77,41 @@ export function toVersionMetadataProp(
|
|
|
74
77
|
pluginId,
|
|
75
78
|
version: loadedVersion.versionName,
|
|
76
79
|
label: loadedVersion.versionLabel,
|
|
80
|
+
banner: loadedVersion.versionBanner,
|
|
81
|
+
badge: loadedVersion.versionBadge,
|
|
82
|
+
className: loadedVersion.versionClassName,
|
|
77
83
|
isLast: loadedVersion.isLast,
|
|
78
84
|
docsSidebars: toSidebarsProp(loadedVersion),
|
|
79
|
-
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function toTagDocListProp({
|
|
89
|
+
allTagsPath,
|
|
90
|
+
tag,
|
|
91
|
+
docs,
|
|
92
|
+
}: {
|
|
93
|
+
allTagsPath: string;
|
|
94
|
+
tag: VersionTag;
|
|
95
|
+
docs: Pick<DocMetadata, 'id' | 'title' | 'description' | 'permalink'>[];
|
|
96
|
+
}): PropTagDocList {
|
|
97
|
+
function toDocListProp(): PropTagDocListDoc[] {
|
|
98
|
+
const list = compact(
|
|
99
|
+
tag.docIds.map((id) => docs.find((doc) => doc.id === id)),
|
|
100
|
+
);
|
|
101
|
+
// Sort docs by title
|
|
102
|
+
list.sort((doc1, doc2) => doc1.title.localeCompare(doc2.title));
|
|
103
|
+
return list.map((doc) => ({
|
|
104
|
+
id: doc.id,
|
|
105
|
+
title: doc.title,
|
|
106
|
+
description: doc.description,
|
|
107
|
+
permalink: doc.permalink,
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
name: tag.name,
|
|
113
|
+
permalink: tag.permalink,
|
|
114
|
+
docs: toDocListProp(),
|
|
115
|
+
allTagsPath,
|
|
80
116
|
};
|
|
81
117
|
}
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-shorthand.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-doc-id-not-string.json
RENAMED
|
File without changes
|
|
File without changes
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-href.json
RENAMED
|
File without changes
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-label.json
RENAMED
|
File without changes
|
|
File without changes
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-unknown-type.json
RENAMED
|
File without changes
|
package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-wrong-field.json
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`loadUnprocessedSidebars sidebars link 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
"docs": Array [
|
|
6
6
|
Object {
|
|
7
7
|
"collapsed": true,
|
|
8
|
+
"collapsible": true,
|
|
8
9
|
"items": Array [
|
|
9
10
|
Object {
|
|
10
11
|
"href": "https://github.com",
|
|
@@ -19,14 +20,16 @@ Object {
|
|
|
19
20
|
}
|
|
20
21
|
`;
|
|
21
22
|
|
|
22
|
-
exports[`
|
|
23
|
+
exports[`loadUnprocessedSidebars sidebars with category.collapsed property 1`] = `
|
|
23
24
|
Object {
|
|
24
25
|
"docs": Array [
|
|
25
26
|
Object {
|
|
26
27
|
"collapsed": true,
|
|
28
|
+
"collapsible": true,
|
|
27
29
|
"items": Array [
|
|
28
30
|
Object {
|
|
29
31
|
"collapsed": false,
|
|
32
|
+
"collapsible": true,
|
|
30
33
|
"items": Array [
|
|
31
34
|
Object {
|
|
32
35
|
"id": "doc1",
|
|
@@ -42,9 +45,11 @@ Object {
|
|
|
42
45
|
},
|
|
43
46
|
Object {
|
|
44
47
|
"collapsed": true,
|
|
48
|
+
"collapsible": true,
|
|
45
49
|
"items": Array [
|
|
46
50
|
Object {
|
|
47
51
|
"collapsed": false,
|
|
52
|
+
"collapsible": true,
|
|
48
53
|
"items": Array [
|
|
49
54
|
Object {
|
|
50
55
|
"id": "doc2",
|
|
@@ -62,11 +67,12 @@ Object {
|
|
|
62
67
|
}
|
|
63
68
|
`;
|
|
64
69
|
|
|
65
|
-
exports[`
|
|
70
|
+
exports[`loadUnprocessedSidebars sidebars with category.collapsed property at first level 1`] = `
|
|
66
71
|
Object {
|
|
67
72
|
"docs": Array [
|
|
68
73
|
Object {
|
|
69
74
|
"collapsed": false,
|
|
75
|
+
"collapsible": true,
|
|
70
76
|
"items": Array [
|
|
71
77
|
Object {
|
|
72
78
|
"id": "doc1",
|
|
@@ -78,6 +84,7 @@ Object {
|
|
|
78
84
|
},
|
|
79
85
|
Object {
|
|
80
86
|
"collapsed": false,
|
|
87
|
+
"collapsible": true,
|
|
81
88
|
"items": Array [
|
|
82
89
|
Object {
|
|
83
90
|
"id": "doc2",
|
|
@@ -91,11 +98,12 @@ Object {
|
|
|
91
98
|
}
|
|
92
99
|
`;
|
|
93
100
|
|
|
94
|
-
exports[`
|
|
101
|
+
exports[`loadUnprocessedSidebars sidebars with deep level of category 1`] = `
|
|
95
102
|
Object {
|
|
96
103
|
"docs": Array [
|
|
97
104
|
Object {
|
|
98
105
|
"collapsed": true,
|
|
106
|
+
"collapsible": true,
|
|
99
107
|
"items": Array [
|
|
100
108
|
Object {
|
|
101
109
|
"id": "a",
|
|
@@ -103,9 +111,11 @@ Object {
|
|
|
103
111
|
},
|
|
104
112
|
Object {
|
|
105
113
|
"collapsed": true,
|
|
114
|
+
"collapsible": true,
|
|
106
115
|
"items": Array [
|
|
107
116
|
Object {
|
|
108
117
|
"collapsed": true,
|
|
118
|
+
"collapsible": true,
|
|
109
119
|
"items": Array [
|
|
110
120
|
Object {
|
|
111
121
|
"id": "c",
|
|
@@ -113,6 +123,7 @@ Object {
|
|
|
113
123
|
},
|
|
114
124
|
Object {
|
|
115
125
|
"collapsed": true,
|
|
126
|
+
"collapsible": true,
|
|
116
127
|
"items": Array [
|
|
117
128
|
Object {
|
|
118
129
|
"id": "d",
|
|
@@ -120,6 +131,7 @@ Object {
|
|
|
120
131
|
},
|
|
121
132
|
Object {
|
|
122
133
|
"collapsed": true,
|
|
134
|
+
"collapsible": true,
|
|
123
135
|
"items": Array [
|
|
124
136
|
Object {
|
|
125
137
|
"id": "e",
|
|
@@ -153,11 +165,12 @@ Object {
|
|
|
153
165
|
}
|
|
154
166
|
`;
|
|
155
167
|
|
|
156
|
-
exports[`
|
|
168
|
+
exports[`loadUnprocessedSidebars sidebars with first level not a category 1`] = `
|
|
157
169
|
Object {
|
|
158
170
|
"docs": Array [
|
|
159
171
|
Object {
|
|
160
172
|
"collapsed": true,
|
|
173
|
+
"collapsible": true,
|
|
161
174
|
"items": Array [
|
|
162
175
|
Object {
|
|
163
176
|
"id": "greeting",
|
|
@@ -175,11 +188,12 @@ Object {
|
|
|
175
188
|
}
|
|
176
189
|
`;
|
|
177
190
|
|
|
178
|
-
exports[`
|
|
191
|
+
exports[`loadUnprocessedSidebars sidebars with known sidebar item type 1`] = `
|
|
179
192
|
Object {
|
|
180
193
|
"docs": Array [
|
|
181
194
|
Object {
|
|
182
195
|
"collapsed": true,
|
|
196
|
+
"collapsible": true,
|
|
183
197
|
"items": Array [
|
|
184
198
|
Object {
|
|
185
199
|
"id": "foo/bar",
|
|
@@ -204,6 +218,7 @@ Object {
|
|
|
204
218
|
},
|
|
205
219
|
Object {
|
|
206
220
|
"collapsed": true,
|
|
221
|
+
"collapsible": true,
|
|
207
222
|
"items": Array [
|
|
208
223
|
Object {
|
|
209
224
|
"id": "hello",
|