@docusaurus/plugin-content-docs 2.0.0-beta.12faed89d → 2.0.0-beta.14
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 +37 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +14 -35
- package/lib/client/docsClientUtils.d.ts +0 -3
- package/lib/client/docsClientUtils.js +19 -22
- package/lib/docFrontMatter.d.ts +1 -1
- package/lib/docFrontMatter.js +7 -3
- package/lib/docs.d.ts +25 -3
- package/lib/docs.js +126 -41
- package/lib/globalData.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +101 -132
- package/lib/lastUpdate.js +12 -12
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.js +2 -2
- package/lib/numberPrefix.d.ts +1 -1
- package/lib/options.d.ts +3 -3
- package/lib/options.js +48 -11
- package/lib/props.d.ts +7 -2
- package/lib/props.js +60 -8
- package/lib/routes.d.ts +27 -0
- package/lib/routes.js +105 -0
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +5 -2
- package/lib/sidebars/generator.js +216 -0
- package/lib/sidebars/index.d.ts +15 -0
- package/lib/sidebars/index.js +73 -0
- package/lib/sidebars/normalization.d.ts +14 -0
- package/lib/sidebars/normalization.js +77 -0
- package/lib/sidebars/processor.d.ts +18 -0
- package/lib/sidebars/processor.js +85 -0
- package/lib/sidebars/types.d.ts +127 -0
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
- package/lib/sidebars/utils.d.ts +35 -0
- package/lib/sidebars/utils.js +228 -0
- package/lib/sidebars/validation.d.ts +10 -0
- package/lib/sidebars/validation.js +138 -0
- package/lib/slug.d.ts +4 -3
- package/lib/slug.js +27 -15
- package/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/tags.d.ts} +2 -8
- package/lib/tags.js +20 -0
- package/lib/theme/hooks/useDocs.js +21 -21
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +71 -29
- package/lib/types.d.ts +52 -63
- package/lib/versions.d.ts +3 -3
- package/lib/versions.js +41 -22
- package/package.json +20 -20
- package/src/categoryGeneratedIndex.ts +57 -0
- package/src/cli.ts +10 -42
- package/src/client/docsClientUtils.ts +14 -26
- package/{types.d.ts → src/deps.d.ts} +0 -0
- package/src/docFrontMatter.ts +9 -4
- package/src/docs.ts +164 -36
- package/src/globalData.ts +6 -1
- package/src/index.ts +127 -175
- package/src/lastUpdate.ts +14 -16
- package/src/markdown/index.ts +8 -12
- package/src/numberPrefix.ts +5 -3
- package/src/options.ts +56 -15
- package/src/plugin-content-docs.d.ts +173 -40
- package/src/props.ts +90 -15
- package/src/routes.ts +169 -0
- package/src/sidebars/generator.ts +302 -0
- package/src/sidebars/index.ts +94 -0
- package/src/sidebars/normalization.ts +112 -0
- package/src/sidebars/processor.ts +154 -0
- package/src/sidebars/types.ts +211 -0
- package/src/sidebars/utils.ts +329 -0
- package/src/sidebars/validation.ts +168 -0
- package/src/slug.ts +32 -17
- package/src/tags.ts +19 -0
- package/src/translations.ts +103 -47
- package/src/types.ts +64 -107
- package/src/versions.ts +59 -25
- package/lib/.tsbuildinfo +0 -1
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -43
- package/lib/sidebars.js +0 -320
- 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 -70
- package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -53
- 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/docusaurus.config.js +0 -14
- 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/docusaurus.config.js +0 -14
- 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/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 -1902
- package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -484
- package/src/__tests__/cli.test.ts +0 -333
- package/src/__tests__/docFrontMatter.test.ts +0 -244
- package/src/__tests__/docs.test.ts +0 -878
- package/src/__tests__/index.test.ts +0 -1868
- package/src/__tests__/lastUpdate.test.ts +0 -69
- package/src/__tests__/numberPrefix.test.ts +0 -199
- package/src/__tests__/options.test.ts +0 -231
- package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
- package/src/__tests__/sidebars.test.ts +0 -639
- package/src/__tests__/slug.test.ts +0 -109
- package/src/__tests__/translations.test.ts +0 -158
- package/src/__tests__/versions.test.ts +0 -741
- package/src/client/__tests__/docsClientUtils.test.ts +0 -371
- 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 -522
- package/tsconfig.json +0 -9
|
@@ -5,51 +5,84 @@
|
|
|
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
|
+
export type VersionBanner = import('./types').VersionBanner;
|
|
12
|
+
type GlobalDataVersion = import('./types').GlobalVersion;
|
|
13
|
+
type GlobalDataDoc = import('./types').GlobalDoc;
|
|
14
|
+
type VersionTag = import('./types').VersionTag;
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
export type {GlobalDataVersion, GlobalDataDoc};
|
|
17
|
+
|
|
18
|
+
export type PropNavigationLink = {
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly permalink: string;
|
|
21
|
+
};
|
|
22
|
+
export type PropNavigation = {
|
|
23
|
+
readonly previous?: PropNavigationLink;
|
|
24
|
+
readonly next?: PropNavigationLink;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type PropVersionDoc = import('./sidebars/types').PropVersionDoc;
|
|
28
|
+
export type PropVersionDocs = import('./sidebars/types').PropVersionDocs;
|
|
12
29
|
|
|
13
30
|
export type PropVersionMetadata = {
|
|
14
31
|
pluginId: string;
|
|
15
32
|
version: string;
|
|
16
33
|
label: string;
|
|
17
|
-
banner: VersionBanner;
|
|
34
|
+
banner: VersionBanner | null;
|
|
35
|
+
badge: boolean;
|
|
36
|
+
className: string;
|
|
18
37
|
isLast: boolean;
|
|
19
38
|
docsSidebars: PropSidebars;
|
|
39
|
+
docs: PropVersionDocs;
|
|
20
40
|
};
|
|
21
41
|
|
|
22
|
-
type
|
|
23
|
-
|
|
42
|
+
export type PropCategoryGeneratedIndex = {
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
slug: string;
|
|
46
|
+
permalink: string;
|
|
47
|
+
navigation: PropNavigation;
|
|
24
48
|
};
|
|
25
49
|
|
|
26
|
-
export type PropSidebarItemLink =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
50
|
+
export type PropSidebarItemLink =
|
|
51
|
+
import('./sidebars/types').PropSidebarItemLink;
|
|
52
|
+
export type PropSidebarItemCategory =
|
|
53
|
+
import('./sidebars/types').PropSidebarItemCategory;
|
|
54
|
+
export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
|
|
55
|
+
export type PropSidebar = import('./sidebars/types').PropSidebar;
|
|
56
|
+
export type PropSidebars = import('./sidebars/types').PropSidebars;
|
|
31
57
|
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
export type PropTagDocListDoc = {
|
|
59
|
+
id: string;
|
|
60
|
+
title: string;
|
|
61
|
+
description: string;
|
|
62
|
+
permalink: string;
|
|
37
63
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
64
|
+
export type PropTagDocList = {
|
|
65
|
+
allTagsPath: string;
|
|
66
|
+
name: string; // normalized name/label of the tag
|
|
67
|
+
permalink: string; // pathname of the tag
|
|
68
|
+
docs: PropTagDocListDoc[];
|
|
43
69
|
};
|
|
44
70
|
|
|
45
|
-
export type {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
71
|
+
export type PropTagsListPage = {
|
|
72
|
+
tags: {
|
|
73
|
+
name: string;
|
|
74
|
+
permalink: string;
|
|
75
|
+
count: number;
|
|
76
|
+
}[];
|
|
77
|
+
};
|
|
49
78
|
}
|
|
50
79
|
|
|
51
80
|
declare module '@theme/DocItem' {
|
|
52
81
|
import type {TOCItem} from '@docusaurus/types';
|
|
82
|
+
import type {
|
|
83
|
+
PropNavigationLink,
|
|
84
|
+
PropVersionMetadata,
|
|
85
|
+
} from '@docusaurus/plugin-content-docs';
|
|
53
86
|
|
|
54
87
|
export type DocumentRoute = {
|
|
55
88
|
readonly component: () => JSX.Element;
|
|
@@ -65,6 +98,8 @@ declare module '@theme/DocItem' {
|
|
|
65
98
|
readonly keywords?: readonly string[];
|
|
66
99
|
readonly hide_title?: boolean;
|
|
67
100
|
readonly hide_table_of_contents?: boolean;
|
|
101
|
+
readonly toc_min_heading_level?: number;
|
|
102
|
+
readonly toc_max_heading_level?: number;
|
|
68
103
|
};
|
|
69
104
|
|
|
70
105
|
export type Metadata = {
|
|
@@ -76,11 +111,15 @@ declare module '@theme/DocItem' {
|
|
|
76
111
|
readonly formattedLastUpdatedAt?: string;
|
|
77
112
|
readonly lastUpdatedBy?: string;
|
|
78
113
|
readonly version?: string;
|
|
79
|
-
readonly previous?:
|
|
80
|
-
readonly next?:
|
|
114
|
+
readonly previous?: PropNavigationLink;
|
|
115
|
+
readonly next?: PropNavigationLink;
|
|
116
|
+
readonly tags: readonly {
|
|
117
|
+
readonly label: string;
|
|
118
|
+
readonly permalink: string;
|
|
119
|
+
}[];
|
|
81
120
|
};
|
|
82
121
|
|
|
83
|
-
export
|
|
122
|
+
export interface Props {
|
|
84
123
|
readonly route: DocumentRoute;
|
|
85
124
|
readonly versionMetadata: PropVersionMetadata;
|
|
86
125
|
readonly content: {
|
|
@@ -90,28 +129,87 @@ declare module '@theme/DocItem' {
|
|
|
90
129
|
readonly contentTitle: string | undefined;
|
|
91
130
|
(): JSX.Element;
|
|
92
131
|
};
|
|
93
|
-
}
|
|
132
|
+
}
|
|
94
133
|
|
|
95
134
|
const DocItem: (props: Props) => JSX.Element;
|
|
96
135
|
export default DocItem;
|
|
97
136
|
}
|
|
98
137
|
|
|
138
|
+
declare module '@theme/DocCard' {
|
|
139
|
+
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
140
|
+
|
|
141
|
+
export interface Props {
|
|
142
|
+
readonly item: PropSidebarItem;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default function DocCard(props: Props): JSX.Element;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare module '@theme/DocCardList' {
|
|
149
|
+
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
150
|
+
|
|
151
|
+
export interface Props {
|
|
152
|
+
readonly items: PropSidebarItem[];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default function DocCardList(props: Props): JSX.Element;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare module '@theme/DocCategoryGeneratedIndexPage' {
|
|
159
|
+
import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
|
|
160
|
+
|
|
161
|
+
export interface Props {
|
|
162
|
+
readonly categoryGeneratedIndex: PropCategoryGeneratedIndex;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export default function DocCategoryGeneratedIndexPage(
|
|
166
|
+
props: Props,
|
|
167
|
+
): JSX.Element;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare module '@theme/DocItemFooter' {
|
|
171
|
+
import type {Props} from '@theme/DocItem';
|
|
172
|
+
|
|
173
|
+
export default function DocItemFooter(props: Props): JSX.Element;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare module '@theme/DocTagsListPage' {
|
|
177
|
+
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
|
|
178
|
+
|
|
179
|
+
export interface Props extends PropTagsListPage {}
|
|
180
|
+
export default function DocTagsListPage(props: Props): JSX.Element;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare module '@theme/DocTagDocListPage' {
|
|
184
|
+
import type {PropTagDocList} from '@docusaurus/plugin-content-docs';
|
|
185
|
+
|
|
186
|
+
export interface Props {
|
|
187
|
+
readonly tag: PropTagDocList;
|
|
188
|
+
}
|
|
189
|
+
export default function DocTagDocListPage(props: Props): JSX.Element;
|
|
190
|
+
}
|
|
191
|
+
|
|
99
192
|
declare module '@theme/DocVersionBanner' {
|
|
100
|
-
|
|
193
|
+
export interface Props {
|
|
194
|
+
readonly className?: string;
|
|
195
|
+
}
|
|
101
196
|
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
};
|
|
197
|
+
export default function DocVersionBanner(props: Props): JSX.Element;
|
|
198
|
+
}
|
|
105
199
|
|
|
106
|
-
|
|
107
|
-
export
|
|
200
|
+
declare module '@theme/DocVersionBadge' {
|
|
201
|
+
export interface Props {
|
|
202
|
+
readonly className?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default function DocVersionBadge(props: Props): JSX.Element;
|
|
108
206
|
}
|
|
109
207
|
|
|
110
208
|
declare module '@theme/DocPage' {
|
|
111
|
-
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs
|
|
209
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
112
210
|
import type {DocumentRoute} from '@theme/DocItem';
|
|
113
211
|
|
|
114
|
-
export
|
|
212
|
+
export interface Props {
|
|
115
213
|
readonly location: {readonly pathname: string};
|
|
116
214
|
readonly versionMetadata: PropVersionMetadata;
|
|
117
215
|
readonly route: {
|
|
@@ -119,20 +217,55 @@ declare module '@theme/DocPage' {
|
|
|
119
217
|
readonly component: () => JSX.Element;
|
|
120
218
|
readonly routes: DocumentRoute[];
|
|
121
219
|
};
|
|
122
|
-
}
|
|
220
|
+
}
|
|
123
221
|
|
|
124
222
|
const DocPage: (props: Props) => JSX.Element;
|
|
125
223
|
export default DocPage;
|
|
126
224
|
}
|
|
127
225
|
|
|
128
226
|
declare module '@theme/Seo' {
|
|
129
|
-
|
|
227
|
+
import type {ReactNode} from 'react';
|
|
228
|
+
|
|
229
|
+
export interface Props {
|
|
130
230
|
readonly title?: string;
|
|
131
231
|
readonly description?: string;
|
|
132
232
|
readonly keywords?: readonly string[] | string;
|
|
133
233
|
readonly image?: string;
|
|
134
|
-
|
|
234
|
+
readonly children?: ReactNode;
|
|
235
|
+
}
|
|
135
236
|
|
|
136
237
|
const Seo: (props: Props) => JSX.Element;
|
|
137
238
|
export default Seo;
|
|
138
239
|
}
|
|
240
|
+
|
|
241
|
+
declare module '@theme/hooks/useDocs' {
|
|
242
|
+
type GlobalPluginData = import('./types').GlobalPluginData;
|
|
243
|
+
type GlobalVersion = import('./types').GlobalVersion;
|
|
244
|
+
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
|
245
|
+
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
|
|
246
|
+
type DocVersionSuggestions =
|
|
247
|
+
import('./client/docsClientUtils').DocVersionSuggestions;
|
|
248
|
+
type GetActivePluginOptions =
|
|
249
|
+
import('./client/docsClientUtils').GetActivePluginOptions;
|
|
250
|
+
|
|
251
|
+
export type {GlobalPluginData, GlobalVersion};
|
|
252
|
+
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
|
253
|
+
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
254
|
+
export const useActivePlugin: (
|
|
255
|
+
options?: GetActivePluginOptions,
|
|
256
|
+
) => ActivePlugin | undefined;
|
|
257
|
+
export const useActivePluginAndVersion: (
|
|
258
|
+
options?: GetActivePluginOptions,
|
|
259
|
+
) =>
|
|
260
|
+
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
261
|
+
| undefined;
|
|
262
|
+
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
263
|
+
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
264
|
+
export const useActiveVersion: (
|
|
265
|
+
pluginId?: string,
|
|
266
|
+
) => GlobalVersion | undefined;
|
|
267
|
+
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
268
|
+
export const useDocVersionSuggestions: (
|
|
269
|
+
pluginId?: string,
|
|
270
|
+
) => DocVersionSuggestions;
|
|
271
|
+
}
|
package/src/props.ts
CHANGED
|
@@ -5,26 +5,31 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import type {LoadedVersion, VersionTag, DocMetadata} from './types';
|
|
9
|
+
import type {
|
|
10
10
|
SidebarItemDoc,
|
|
11
|
-
SidebarItemLink,
|
|
12
11
|
SidebarItem,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
SidebarItemCategory,
|
|
13
|
+
SidebarItemCategoryLink,
|
|
14
|
+
PropVersionDocs,
|
|
15
|
+
} from './sidebars/types';
|
|
16
|
+
import type {
|
|
15
17
|
PropSidebars,
|
|
16
18
|
PropVersionMetadata,
|
|
17
19
|
PropSidebarItem,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
PropSidebarItemCategory,
|
|
21
|
+
PropTagDocList,
|
|
22
|
+
PropTagDocListDoc,
|
|
23
|
+
PropSidebarItemLink,
|
|
24
|
+
} from '@docusaurus/plugin-content-docs';
|
|
25
|
+
import {compact, keyBy, mapValues} from 'lodash';
|
|
26
|
+
import {createDocsByIdIndex} from './docs';
|
|
20
27
|
|
|
21
28
|
export function toSidebarsProp(loadedVersion: LoadedVersion): PropSidebars {
|
|
22
|
-
const docsById =
|
|
29
|
+
const docsById = createDocsByIdIndex(loadedVersion.docs);
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
const docId = item.id;
|
|
31
|
+
function getDocById(docId: string): DocMetadata {
|
|
26
32
|
const docMetadata = docsById[docId];
|
|
27
|
-
|
|
28
33
|
if (!docMetadata) {
|
|
29
34
|
throw new Error(
|
|
30
35
|
`Invalid sidebars file. The document with id "${docId}" was used in the sidebar, but no document with this id could be found.
|
|
@@ -32,25 +37,49 @@ Available document ids are:
|
|
|
32
37
|
- ${Object.keys(docsById).sort().join('\n- ')}`,
|
|
33
38
|
);
|
|
34
39
|
}
|
|
40
|
+
return docMetadata;
|
|
41
|
+
}
|
|
35
42
|
|
|
43
|
+
const convertDocLink = (item: SidebarItemDoc): PropSidebarItemLink => {
|
|
44
|
+
const docMetadata = getDocById(item.id);
|
|
36
45
|
const {
|
|
37
46
|
title,
|
|
38
47
|
permalink,
|
|
39
48
|
frontMatter: {sidebar_label: sidebarLabel},
|
|
40
49
|
} = docMetadata;
|
|
41
|
-
|
|
42
50
|
return {
|
|
43
51
|
type: 'link',
|
|
44
52
|
label: sidebarLabel || item.label || title,
|
|
45
53
|
href: permalink,
|
|
54
|
+
className: item.className,
|
|
46
55
|
customProps: item.customProps,
|
|
56
|
+
docId: docMetadata.unversionedId,
|
|
47
57
|
};
|
|
48
58
|
};
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
function getCategoryLinkHref(
|
|
61
|
+
link: SidebarItemCategoryLink | undefined,
|
|
62
|
+
): string | undefined {
|
|
63
|
+
switch (link?.type) {
|
|
64
|
+
case 'doc':
|
|
65
|
+
return getDocById(link.id).permalink;
|
|
66
|
+
case 'generated-index':
|
|
67
|
+
return link.permalink;
|
|
68
|
+
default:
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function convertCategory(item: SidebarItemCategory): PropSidebarItemCategory {
|
|
74
|
+
const {link, ...rest} = item;
|
|
75
|
+
const href = getCategoryLinkHref(link);
|
|
76
|
+
return {...rest, items: item.items.map(normalizeItem), ...(href && {href})};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function normalizeItem(item: SidebarItem): PropSidebarItem {
|
|
51
80
|
switch (item.type) {
|
|
52
81
|
case 'category':
|
|
53
|
-
return
|
|
82
|
+
return convertCategory(item);
|
|
54
83
|
case 'ref':
|
|
55
84
|
case 'doc':
|
|
56
85
|
return convertDocLink(item);
|
|
@@ -58,7 +87,7 @@ Available document ids are:
|
|
|
58
87
|
default:
|
|
59
88
|
return item;
|
|
60
89
|
}
|
|
61
|
-
}
|
|
90
|
+
}
|
|
62
91
|
|
|
63
92
|
// Transform the sidebar so that all sidebar item will be in the
|
|
64
93
|
// form of 'link' or 'category' only.
|
|
@@ -66,6 +95,18 @@ Available document ids are:
|
|
|
66
95
|
return mapValues(loadedVersion.sidebars, (items) => items.map(normalizeItem));
|
|
67
96
|
}
|
|
68
97
|
|
|
98
|
+
function toVersionDocsProp(loadedVersion: LoadedVersion): PropVersionDocs {
|
|
99
|
+
return mapValues(
|
|
100
|
+
keyBy(loadedVersion.docs, (doc) => doc.unversionedId),
|
|
101
|
+
(doc) => ({
|
|
102
|
+
id: doc.unversionedId,
|
|
103
|
+
title: doc.title,
|
|
104
|
+
description: doc.description,
|
|
105
|
+
sidebar: doc.sidebar,
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
69
110
|
export function toVersionMetadataProp(
|
|
70
111
|
pluginId: string,
|
|
71
112
|
loadedVersion: LoadedVersion,
|
|
@@ -75,7 +116,41 @@ export function toVersionMetadataProp(
|
|
|
75
116
|
version: loadedVersion.versionName,
|
|
76
117
|
label: loadedVersion.versionLabel,
|
|
77
118
|
banner: loadedVersion.versionBanner,
|
|
119
|
+
badge: loadedVersion.versionBadge,
|
|
120
|
+
className: loadedVersion.versionClassName,
|
|
78
121
|
isLast: loadedVersion.isLast,
|
|
79
122
|
docsSidebars: toSidebarsProp(loadedVersion),
|
|
123
|
+
docs: toVersionDocsProp(loadedVersion),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function toTagDocListProp({
|
|
128
|
+
allTagsPath,
|
|
129
|
+
tag,
|
|
130
|
+
docs,
|
|
131
|
+
}: {
|
|
132
|
+
allTagsPath: string;
|
|
133
|
+
tag: VersionTag;
|
|
134
|
+
docs: Pick<DocMetadata, 'id' | 'title' | 'description' | 'permalink'>[];
|
|
135
|
+
}): PropTagDocList {
|
|
136
|
+
function toDocListProp(): PropTagDocListDoc[] {
|
|
137
|
+
const list = compact(
|
|
138
|
+
tag.docIds.map((id) => docs.find((doc) => doc.id === id)),
|
|
139
|
+
);
|
|
140
|
+
// Sort docs by title
|
|
141
|
+
list.sort((doc1, doc2) => doc1.title.localeCompare(doc2.title));
|
|
142
|
+
return list.map((doc) => ({
|
|
143
|
+
id: doc.id,
|
|
144
|
+
title: doc.title,
|
|
145
|
+
description: doc.description,
|
|
146
|
+
permalink: doc.permalink,
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
name: tag.name,
|
|
152
|
+
permalink: tag.permalink,
|
|
153
|
+
docs: toDocListProp(),
|
|
154
|
+
allTagsPath,
|
|
80
155
|
};
|
|
81
156
|
}
|
package/src/routes.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {PluginContentLoadedActions, RouteConfig} from '@docusaurus/types';
|
|
9
|
+
import {docuHash, createSlugger} from '@docusaurus/utils';
|
|
10
|
+
import {
|
|
11
|
+
CategoryGeneratedIndexMetadata,
|
|
12
|
+
DocMetadata,
|
|
13
|
+
LoadedVersion,
|
|
14
|
+
} from './types';
|
|
15
|
+
import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
|
|
16
|
+
import {toVersionMetadataProp} from './props';
|
|
17
|
+
import logger from '@docusaurus/logger';
|
|
18
|
+
|
|
19
|
+
export async function createCategoryGeneratedIndexRoutes({
|
|
20
|
+
version,
|
|
21
|
+
actions,
|
|
22
|
+
docCategoryGeneratedIndexComponent,
|
|
23
|
+
}: {
|
|
24
|
+
version: LoadedVersion;
|
|
25
|
+
actions: PluginContentLoadedActions;
|
|
26
|
+
docCategoryGeneratedIndexComponent: string;
|
|
27
|
+
}): Promise<RouteConfig[]> {
|
|
28
|
+
const slugs = createSlugger();
|
|
29
|
+
|
|
30
|
+
async function createCategoryGeneratedIndexRoute(
|
|
31
|
+
categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
|
|
32
|
+
): Promise<RouteConfig> {
|
|
33
|
+
const {sidebar, title, description, slug, permalink, previous, next} =
|
|
34
|
+
categoryGeneratedIndex;
|
|
35
|
+
|
|
36
|
+
const propFileName = slugs.slug(
|
|
37
|
+
`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const prop: PropCategoryGeneratedIndex = {
|
|
41
|
+
title,
|
|
42
|
+
description,
|
|
43
|
+
slug,
|
|
44
|
+
permalink,
|
|
45
|
+
navigation: {
|
|
46
|
+
previous,
|
|
47
|
+
next,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const propData = await actions.createData(
|
|
52
|
+
`${docuHash(`category/${propFileName}`)}.json`,
|
|
53
|
+
JSON.stringify(prop, null, 2),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
path: permalink,
|
|
58
|
+
component: docCategoryGeneratedIndexComponent,
|
|
59
|
+
exact: true,
|
|
60
|
+
modules: {
|
|
61
|
+
categoryGeneratedIndex: propData,
|
|
62
|
+
},
|
|
63
|
+
// Same as doc, this sidebar route attribute permits to associate this subpage to the given sidebar
|
|
64
|
+
...(sidebar && {sidebar}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return Promise.all(
|
|
69
|
+
version.categoryGeneratedIndices.map(createCategoryGeneratedIndexRoute),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function createDocRoutes({
|
|
74
|
+
docs,
|
|
75
|
+
actions,
|
|
76
|
+
docItemComponent,
|
|
77
|
+
}: {
|
|
78
|
+
docs: DocMetadata[];
|
|
79
|
+
actions: PluginContentLoadedActions;
|
|
80
|
+
docItemComponent: string;
|
|
81
|
+
}): Promise<RouteConfig[]> {
|
|
82
|
+
return Promise.all(
|
|
83
|
+
docs.map(async (metadataItem) => {
|
|
84
|
+
await actions.createData(
|
|
85
|
+
// Note that this created data path must be in sync with
|
|
86
|
+
// metadataPath provided to mdx-loader.
|
|
87
|
+
`${docuHash(metadataItem.source)}.json`,
|
|
88
|
+
JSON.stringify(metadataItem, null, 2),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const docRoute: RouteConfig = {
|
|
92
|
+
path: metadataItem.permalink,
|
|
93
|
+
component: docItemComponent,
|
|
94
|
+
exact: true,
|
|
95
|
+
modules: {
|
|
96
|
+
content: metadataItem.source,
|
|
97
|
+
},
|
|
98
|
+
// Because the parent (DocPage) comp need to access it easily
|
|
99
|
+
// This permits to render the sidebar once without unmount/remount when navigating (and preserve sidebar state)
|
|
100
|
+
...(metadataItem.sidebar && {
|
|
101
|
+
sidebar: metadataItem.sidebar,
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return docRoute;
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function createVersionRoutes({
|
|
111
|
+
loadedVersion,
|
|
112
|
+
actions,
|
|
113
|
+
docItemComponent,
|
|
114
|
+
docLayoutComponent,
|
|
115
|
+
docCategoryGeneratedIndexComponent,
|
|
116
|
+
pluginId,
|
|
117
|
+
aliasedSource,
|
|
118
|
+
}: {
|
|
119
|
+
loadedVersion: LoadedVersion;
|
|
120
|
+
actions: PluginContentLoadedActions;
|
|
121
|
+
docLayoutComponent: string;
|
|
122
|
+
docItemComponent: string;
|
|
123
|
+
docCategoryGeneratedIndexComponent: string;
|
|
124
|
+
pluginId: string;
|
|
125
|
+
aliasedSource: (str: string) => string;
|
|
126
|
+
}): Promise<void> {
|
|
127
|
+
async function doCreateVersionRoutes(version: LoadedVersion): Promise<void> {
|
|
128
|
+
const versionMetadata = toVersionMetadataProp(pluginId, version);
|
|
129
|
+
const versionMetadataPropPath = await actions.createData(
|
|
130
|
+
`${docuHash(`version-${version.versionName}-metadata-prop`)}.json`,
|
|
131
|
+
JSON.stringify(versionMetadata, null, 2),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
async function createVersionSubRoutes() {
|
|
135
|
+
const [docRoutes, sidebarsRoutes] = await Promise.all([
|
|
136
|
+
createDocRoutes({docs: version.docs, actions, docItemComponent}),
|
|
137
|
+
createCategoryGeneratedIndexRoutes({
|
|
138
|
+
version,
|
|
139
|
+
actions,
|
|
140
|
+
docCategoryGeneratedIndexComponent,
|
|
141
|
+
}),
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
const routes = [...docRoutes, ...sidebarsRoutes];
|
|
145
|
+
return routes.sort((a, b) => a.path.localeCompare(b.path));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
actions.addRoute({
|
|
149
|
+
path: version.versionPath,
|
|
150
|
+
// allow matching /docs/* as well
|
|
151
|
+
exact: false,
|
|
152
|
+
// main docs component (DocPage)
|
|
153
|
+
component: docLayoutComponent,
|
|
154
|
+
// sub-routes for each doc
|
|
155
|
+
routes: await createVersionSubRoutes(),
|
|
156
|
+
modules: {
|
|
157
|
+
versionMetadata: aliasedSource(versionMetadataPropPath),
|
|
158
|
+
},
|
|
159
|
+
priority: version.routePriority,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
return await doCreateVersionRoutes(loadedVersion);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
logger.error`Can't create version routes for version name=${loadedVersion.versionName}`;
|
|
167
|
+
throw e;
|
|
168
|
+
}
|
|
169
|
+
}
|