@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/lib/types.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { RemarkAndRehypePluginOptions } from '@docusaurus/mdx-loader';
|
|
8
|
-
import {
|
|
8
|
+
import type { Tag, FrontMatterTag } from '@docusaurus/utils';
|
|
9
|
+
import type { BrokenMarkdownLink as IBrokenMarkdownLink, ContentPaths } from '@docusaurus/utils/lib/markdownLinks';
|
|
10
|
+
import type { SidebarItemsGeneratorOption, Sidebars } from './sidebars/types';
|
|
9
11
|
export declare type DocFile = {
|
|
10
12
|
contentPath: string;
|
|
11
13
|
filePath: string;
|
|
@@ -18,8 +20,12 @@ export declare type VersionMetadata = ContentPaths & {
|
|
|
18
20
|
versionName: VersionName;
|
|
19
21
|
versionLabel: string;
|
|
20
22
|
versionPath: string;
|
|
23
|
+
tagsPath: string;
|
|
21
24
|
versionEditUrl?: string | undefined;
|
|
22
25
|
versionEditUrlLocalized?: string | undefined;
|
|
26
|
+
versionBanner: VersionBanner | null;
|
|
27
|
+
versionBadge: boolean;
|
|
28
|
+
versionClassName: string;
|
|
23
29
|
isLast: boolean;
|
|
24
30
|
sidebarFilePath: string | false | undefined;
|
|
25
31
|
routePriority: number | undefined;
|
|
@@ -45,79 +51,36 @@ export declare type PathOptions = {
|
|
|
45
51
|
path: string;
|
|
46
52
|
sidebarPath?: string | false | undefined;
|
|
47
53
|
};
|
|
54
|
+
export declare type VersionBanner = 'unreleased' | 'unmaintained';
|
|
48
55
|
export declare type VersionOptions = {
|
|
49
56
|
path?: string;
|
|
50
57
|
label?: string;
|
|
58
|
+
banner?: 'none' | VersionBanner;
|
|
59
|
+
badge?: boolean;
|
|
60
|
+
className?: string;
|
|
51
61
|
};
|
|
52
62
|
export declare type VersionsOptions = {
|
|
53
63
|
lastVersion?: string;
|
|
54
64
|
versions: Record<string, VersionOptions>;
|
|
55
65
|
onlyIncludeVersions?: string[];
|
|
56
66
|
};
|
|
57
|
-
export declare type
|
|
67
|
+
export declare type SidebarOptions = {
|
|
68
|
+
sidebarCollapsible: boolean;
|
|
69
|
+
sidebarCollapsed: boolean;
|
|
70
|
+
};
|
|
71
|
+
export declare type PluginOptions = MetadataOptions & PathOptions & VersionsOptions & RemarkAndRehypePluginOptions & SidebarOptions & {
|
|
58
72
|
id: string;
|
|
59
73
|
include: string[];
|
|
74
|
+
exclude: string[];
|
|
60
75
|
docLayoutComponent: string;
|
|
61
76
|
docItemComponent: string;
|
|
77
|
+
docTagDocListComponent: string;
|
|
78
|
+
docTagsListComponent: string;
|
|
62
79
|
admonitions: Record<string, unknown>;
|
|
63
80
|
disableVersioning: boolean;
|
|
64
|
-
excludeNextVersionDocs?: boolean;
|
|
65
81
|
includeCurrentVersion: boolean;
|
|
66
82
|
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
|
67
|
-
|
|
68
|
-
export declare type SidebarItemBase = {
|
|
69
|
-
customProps?: Record<string, unknown>;
|
|
70
|
-
};
|
|
71
|
-
export declare type SidebarItemDoc = SidebarItemBase & {
|
|
72
|
-
type: 'doc' | 'ref';
|
|
73
|
-
label?: string;
|
|
74
|
-
id: string;
|
|
75
|
-
};
|
|
76
|
-
export declare type SidebarItemLink = SidebarItemBase & {
|
|
77
|
-
type: 'link';
|
|
78
|
-
href: string;
|
|
79
|
-
label: string;
|
|
80
|
-
};
|
|
81
|
-
export declare type SidebarItemCategory = SidebarItemBase & {
|
|
82
|
-
type: 'category';
|
|
83
|
-
label: string;
|
|
84
|
-
items: SidebarItem[];
|
|
85
|
-
collapsed: boolean;
|
|
86
|
-
};
|
|
87
|
-
export declare type UnprocessedSidebarItemAutogenerated = {
|
|
88
|
-
type: 'autogenerated';
|
|
89
|
-
dirName: string;
|
|
90
|
-
};
|
|
91
|
-
export declare type UnprocessedSidebarItemCategory = SidebarItemBase & {
|
|
92
|
-
type: 'category';
|
|
93
|
-
label: string;
|
|
94
|
-
items: UnprocessedSidebarItem[];
|
|
95
|
-
collapsed: boolean;
|
|
96
|
-
};
|
|
97
|
-
export declare type UnprocessedSidebarItem = SidebarItemDoc | SidebarItemLink | UnprocessedSidebarItemCategory | UnprocessedSidebarItemAutogenerated;
|
|
98
|
-
export declare type UnprocessedSidebar = UnprocessedSidebarItem[];
|
|
99
|
-
export declare type UnprocessedSidebars = Record<string, UnprocessedSidebar>;
|
|
100
|
-
export declare type SidebarItem = SidebarItemDoc | SidebarItemLink | SidebarItemCategory;
|
|
101
|
-
export declare type Sidebar = SidebarItem[];
|
|
102
|
-
export declare type SidebarItemType = SidebarItem['type'];
|
|
103
|
-
export declare type Sidebars = Record<string, Sidebar>;
|
|
104
|
-
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
105
|
-
export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
|
|
106
|
-
export declare type SidebarItemsGeneratorArgs = {
|
|
107
|
-
item: UnprocessedSidebarItemAutogenerated;
|
|
108
|
-
version: SidebarItemsGeneratorVersion;
|
|
109
|
-
docs: SidebarItemsGeneratorDoc[];
|
|
110
|
-
numberPrefixParser: NumberPrefixParser;
|
|
111
|
-
};
|
|
112
|
-
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<SidebarItem[]>;
|
|
113
|
-
export declare type SidebarItemsGeneratorOptionArgs = {
|
|
114
|
-
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
|
115
|
-
} & SidebarItemsGeneratorArgs;
|
|
116
|
-
export declare type SidebarItemsGeneratorOption = (generatorArgs: SidebarItemsGeneratorOptionArgs) => Promise<SidebarItem[]>;
|
|
117
|
-
export declare type OrderMetadata = {
|
|
118
|
-
previous?: string;
|
|
119
|
-
next?: string;
|
|
120
|
-
sidebar?: string;
|
|
83
|
+
tagsBasePath: string;
|
|
121
84
|
};
|
|
122
85
|
export declare type LastUpdateData = {
|
|
123
86
|
lastUpdatedAt?: number;
|
|
@@ -127,6 +90,7 @@ export declare type LastUpdateData = {
|
|
|
127
90
|
export declare type DocFrontMatter = {
|
|
128
91
|
id?: string;
|
|
129
92
|
title?: string;
|
|
93
|
+
tags?: FrontMatterTag[];
|
|
130
94
|
hide_title?: boolean;
|
|
131
95
|
hide_table_of_contents?: boolean;
|
|
132
96
|
keywords?: string[];
|
|
@@ -135,9 +99,14 @@ export declare type DocFrontMatter = {
|
|
|
135
99
|
slug?: string;
|
|
136
100
|
sidebar_label?: string;
|
|
137
101
|
sidebar_position?: number;
|
|
102
|
+
sidebar_class_name?: string;
|
|
138
103
|
pagination_label?: string;
|
|
139
104
|
custom_edit_url?: string | null;
|
|
140
105
|
parse_number_prefixes?: boolean;
|
|
106
|
+
toc_min_heading_level?: number;
|
|
107
|
+
toc_max_heading_level?: number;
|
|
108
|
+
pagination_next?: string | null;
|
|
109
|
+
pagination_prev?: string | null;
|
|
141
110
|
};
|
|
142
111
|
export declare type DocMetadataBase = LastUpdateData & {
|
|
143
112
|
version: VersionName;
|
|
@@ -152,6 +121,7 @@ export declare type DocMetadataBase = LastUpdateData & {
|
|
|
152
121
|
permalink: string;
|
|
153
122
|
sidebarPosition?: number;
|
|
154
123
|
editUrl?: string | null;
|
|
124
|
+
tags: Tag[];
|
|
155
125
|
frontMatter: DocFrontMatter & Record<string, unknown>;
|
|
156
126
|
};
|
|
157
127
|
export declare type DocNavLink = {
|
|
@@ -166,12 +136,19 @@ export declare type DocMetadata = DocMetadataBase & {
|
|
|
166
136
|
export declare type SourceToPermalink = {
|
|
167
137
|
[source: string]: string;
|
|
168
138
|
};
|
|
139
|
+
export declare type VersionTag = {
|
|
140
|
+
name: string;
|
|
141
|
+
docIds: string[];
|
|
142
|
+
permalink: string;
|
|
143
|
+
};
|
|
144
|
+
export declare type VersionTags = {
|
|
145
|
+
[key: string]: VersionTag;
|
|
146
|
+
};
|
|
169
147
|
export declare type LoadedVersion = VersionMetadata & {
|
|
170
148
|
versionPath: string;
|
|
171
149
|
mainDocId: string;
|
|
172
150
|
docs: DocMetadata[];
|
|
173
151
|
sidebars: Sidebars;
|
|
174
|
-
permalinkToSidebar: Record<string, string>;
|
|
175
152
|
};
|
|
176
153
|
export declare type LoadedContent = {
|
|
177
154
|
loadedVersions: LoadedVersion[];
|
package/lib/versions.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: s
|
|
|
11
11
|
export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
|
|
12
12
|
export declare function readVersionsMetadata({ context, options, }: {
|
|
13
13
|
context: Pick<LoadContext, 'siteDir' | 'baseUrl' | 'i18n'>;
|
|
14
|
-
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
14
|
+
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'tagsBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
15
15
|
}): VersionMetadata[];
|
|
16
16
|
export declare function getDocsDirPaths(versionMetadata: Pick<VersionMetadata, 'contentPath' | 'contentPathLocalized'>): [string, string];
|
package/lib/versions.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getDocsDirPaths = exports.readVersionsMetadata = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const constants_2 = require("@docusaurus/core/lib/constants");
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -83,7 +83,7 @@ function readVersionNames(siteDir, options) {
|
|
|
83
83
|
return versions;
|
|
84
84
|
}
|
|
85
85
|
function getDocsDirPathLocalized({ siteDir, locale, pluginId, versionName, }) {
|
|
86
|
-
return utils_1.getPluginI18nPath({
|
|
86
|
+
return (0, utils_1.getPluginI18nPath)({
|
|
87
87
|
siteDir,
|
|
88
88
|
locale,
|
|
89
89
|
pluginName: 'docusaurus-plugin-content-docs',
|
|
@@ -108,7 +108,7 @@ function getVersionMetadataPaths({ versionName, context, options, }) {
|
|
|
108
108
|
});
|
|
109
109
|
function getSidebarFilePath() {
|
|
110
110
|
if (isCurrentVersion) {
|
|
111
|
-
return sidebars_1.resolveSidebarPathOption(context.siteDir, options.sidebarPath);
|
|
111
|
+
return (0, sidebars_1.resolveSidebarPathOption)(context.siteDir, options.sidebarPath);
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
return path_1.default.join(getVersionedSidebarsDirPath(context.siteDir, options.id), `version-${versionName}-sidebars.json`);
|
|
@@ -138,10 +138,10 @@ function getVersionEditUrls({ contentPath, contentPathLocalized, context: { site
|
|
|
138
138
|
pluginId: id,
|
|
139
139
|
})
|
|
140
140
|
: contentPathLocalized;
|
|
141
|
-
const versionPathSegment = utils_1.posixPath(path_1.default.relative(siteDir, path_1.default.resolve(siteDir, editDirPath)));
|
|
142
|
-
const versionPathSegmentLocalized = utils_1.posixPath(path_1.default.relative(siteDir, path_1.default.resolve(siteDir, editDirPathLocalized)));
|
|
143
|
-
const versionEditUrl = utils_1.normalizeUrl([editUrl, versionPathSegment]);
|
|
144
|
-
const versionEditUrlLocalized = utils_1.normalizeUrl([
|
|
141
|
+
const versionPathSegment = (0, utils_1.posixPath)(path_1.default.relative(siteDir, path_1.default.resolve(siteDir, editDirPath)));
|
|
142
|
+
const versionPathSegmentLocalized = (0, utils_1.posixPath)(path_1.default.relative(siteDir, path_1.default.resolve(siteDir, editDirPathLocalized)));
|
|
143
|
+
const versionEditUrl = (0, utils_1.normalizeUrl)([editUrl, versionPathSegment]);
|
|
144
|
+
const versionEditUrlLocalized = (0, utils_1.normalizeUrl)([
|
|
145
145
|
editUrl,
|
|
146
146
|
versionPathSegmentLocalized,
|
|
147
147
|
]);
|
|
@@ -150,24 +150,64 @@ function getVersionEditUrls({ contentPath, contentPathLocalized, context: { site
|
|
|
150
150
|
versionEditUrlLocalized,
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }) {
|
|
154
|
+
// Current version: good, no banner
|
|
155
|
+
if (versionName === lastVersionName) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
// Upcoming versions: unreleased banner
|
|
159
|
+
else if (versionNames.indexOf(versionName) < versionNames.indexOf(lastVersionName)) {
|
|
160
|
+
return 'unreleased';
|
|
161
|
+
}
|
|
162
|
+
// Older versions: display unmaintained banner
|
|
163
|
+
else {
|
|
164
|
+
return 'unmaintained';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function getVersionBanner({ versionName, versionNames, lastVersionName, options, }) {
|
|
168
|
+
var _a;
|
|
169
|
+
const versionBannerOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.banner;
|
|
170
|
+
if (versionBannerOption) {
|
|
171
|
+
return versionBannerOption === 'none' ? null : versionBannerOption;
|
|
172
|
+
}
|
|
173
|
+
return getDefaultVersionBanner({
|
|
156
174
|
versionName,
|
|
157
|
-
|
|
158
|
-
|
|
175
|
+
versionNames,
|
|
176
|
+
lastVersionName,
|
|
159
177
|
});
|
|
178
|
+
}
|
|
179
|
+
function getVersionBadge({ versionName, versionNames, options, }) {
|
|
180
|
+
var _a;
|
|
181
|
+
const versionBadgeOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.badge;
|
|
182
|
+
// If site is not versioned or only one version is included
|
|
183
|
+
// we don't show the version badge by default
|
|
184
|
+
// See https://github.com/facebook/docusaurus/issues/3362
|
|
185
|
+
const versionBadgeDefault = versionNames.length !== 1;
|
|
186
|
+
return versionBadgeOption !== null && versionBadgeOption !== void 0 ? versionBadgeOption : versionBadgeDefault;
|
|
187
|
+
}
|
|
188
|
+
function getVersionClassName({ versionName, options, }) {
|
|
189
|
+
var _a;
|
|
190
|
+
const versionClassNameOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.className;
|
|
191
|
+
const versionClassNameDefault = `docs-version-${versionName}`;
|
|
192
|
+
return versionClassNameOption !== null && versionClassNameOption !== void 0 ? versionClassNameOption : versionClassNameDefault;
|
|
193
|
+
}
|
|
194
|
+
function createVersionMetadata({ versionName, versionNames, lastVersionName, context, options, }) {
|
|
195
|
+
var _a, _b, _c;
|
|
196
|
+
const { sidebarFilePath, contentPath, contentPathLocalized } = getVersionMetadataPaths({ versionName, context, options });
|
|
197
|
+
const isLast = versionName === lastVersionName;
|
|
160
198
|
// retro-compatible values
|
|
161
199
|
const defaultVersionLabel = versionName === constants_1.CURRENT_VERSION_NAME ? 'Next' : versionName;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
200
|
+
function getDefaultVersionPathPart() {
|
|
201
|
+
if (isLast) {
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
return versionName === constants_1.CURRENT_VERSION_NAME ? 'next' : versionName;
|
|
205
|
+
}
|
|
206
|
+
const defaultVersionPathPart = getDefaultVersionPathPart();
|
|
167
207
|
const versionOptions = (_a = options.versions[versionName]) !== null && _a !== void 0 ? _a : {};
|
|
168
208
|
const versionLabel = (_b = versionOptions.label) !== null && _b !== void 0 ? _b : defaultVersionLabel;
|
|
169
209
|
const versionPathPart = (_c = versionOptions.path) !== null && _c !== void 0 ? _c : defaultVersionPathPart;
|
|
170
|
-
const versionPath = utils_1.normalizeUrl([
|
|
210
|
+
const versionPath = (0, utils_1.normalizeUrl)([
|
|
171
211
|
context.baseUrl,
|
|
172
212
|
options.routeBasePath,
|
|
173
213
|
versionPathPart,
|
|
@@ -180,12 +220,24 @@ function createVersionMetadata({ versionName, isLast, context, options, }) {
|
|
|
180
220
|
});
|
|
181
221
|
// Because /docs/:route` should always be after `/docs/versionName/:route`.
|
|
182
222
|
const routePriority = versionPathPart === '' ? -1 : undefined;
|
|
223
|
+
// the path that will be used to refer the docs tags
|
|
224
|
+
// example below will be using /docs/tags
|
|
225
|
+
const tagsPath = (0, utils_1.normalizeUrl)([versionPath, options.tagsBasePath]);
|
|
183
226
|
return {
|
|
184
227
|
versionName,
|
|
185
228
|
versionLabel,
|
|
186
229
|
versionPath,
|
|
230
|
+
tagsPath,
|
|
187
231
|
versionEditUrl: versionEditUrls === null || versionEditUrls === void 0 ? void 0 : versionEditUrls.versionEditUrl,
|
|
188
232
|
versionEditUrlLocalized: versionEditUrls === null || versionEditUrls === void 0 ? void 0 : versionEditUrls.versionEditUrlLocalized,
|
|
233
|
+
versionBanner: getVersionBanner({
|
|
234
|
+
versionName,
|
|
235
|
+
versionNames,
|
|
236
|
+
lastVersionName,
|
|
237
|
+
options,
|
|
238
|
+
}),
|
|
239
|
+
versionBadge: getVersionBadge({ versionName, versionNames, options }),
|
|
240
|
+
versionClassName: getVersionClassName({ versionName, options }),
|
|
189
241
|
isLast,
|
|
190
242
|
routePriority,
|
|
191
243
|
sidebarFilePath,
|
|
@@ -231,7 +283,7 @@ function checkVersionsOptions(availableVersionNames, options) {
|
|
|
231
283
|
!availableVersionNames.includes(options.lastVersion)) {
|
|
232
284
|
throw new Error(`Docs option lastVersion=${options.lastVersion} is invalid. ${availableVersionNamesMsg}`);
|
|
233
285
|
}
|
|
234
|
-
const unknownVersionConfigNames = lodash_1.difference(Object.keys(options.versions), availableVersionNames);
|
|
286
|
+
const unknownVersionConfigNames = (0, lodash_1.difference)(Object.keys(options.versions), availableVersionNames);
|
|
235
287
|
if (unknownVersionConfigNames.length > 0) {
|
|
236
288
|
throw new Error(`Invalid docs option "versions": unknown versions (${unknownVersionConfigNames.join(',')}) found. ${availableVersionNamesMsg}`);
|
|
237
289
|
}
|
|
@@ -239,7 +291,7 @@ function checkVersionsOptions(availableVersionNames, options) {
|
|
|
239
291
|
if (options.onlyIncludeVersions.length === 0) {
|
|
240
292
|
throw new Error(`Invalid docs option "onlyIncludeVersions": an empty array is not allowed, at least one version is needed.`);
|
|
241
293
|
}
|
|
242
|
-
const unknownOnlyIncludeVersionNames = lodash_1.difference(options.onlyIncludeVersions, availableVersionNames);
|
|
294
|
+
const unknownOnlyIncludeVersionNames = (0, lodash_1.difference)(options.onlyIncludeVersions, availableVersionNames);
|
|
243
295
|
if (unknownOnlyIncludeVersionNames.length > 0) {
|
|
244
296
|
throw new Error(`Invalid docs option "onlyIncludeVersions": unknown versions (${unknownOnlyIncludeVersionNames.join(',')}) found. ${availableVersionNamesMsg}`);
|
|
245
297
|
}
|
|
@@ -269,7 +321,8 @@ function readVersionsMetadata({ context, options, }) {
|
|
|
269
321
|
const lastVersionName = (_a = options.lastVersion) !== null && _a !== void 0 ? _a : getDefaultLastVersionName(versionNames);
|
|
270
322
|
const versionsMetadata = versionNames.map((versionName) => createVersionMetadata({
|
|
271
323
|
versionName,
|
|
272
|
-
|
|
324
|
+
versionNames,
|
|
325
|
+
lastVersionName,
|
|
273
326
|
context,
|
|
274
327
|
options,
|
|
275
328
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-docs.d.ts",
|
|
@@ -18,19 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
21
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.9",
|
|
22
22
|
"@types/js-yaml": "^4.0.0",
|
|
23
23
|
"@types/picomatch": "^2.2.1",
|
|
24
24
|
"commander": "^5.1.0",
|
|
25
|
-
"picomatch": "^2.1.1"
|
|
25
|
+
"picomatch": "^2.1.1",
|
|
26
|
+
"utility-types": "^3.10.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/mdx-loader": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
31
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
33
|
-
"chalk": "^4.1.
|
|
29
|
+
"@docusaurus/core": "2.0.0-beta.9",
|
|
30
|
+
"@docusaurus/mdx-loader": "2.0.0-beta.9",
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.9",
|
|
32
|
+
"@docusaurus/utils": "2.0.0-beta.9",
|
|
33
|
+
"@docusaurus/utils-validation": "2.0.0-beta.9",
|
|
34
|
+
"chalk": "^4.1.2",
|
|
34
35
|
"combine-promises": "^1.1.0",
|
|
35
36
|
"escape-string-regexp": "^4.0.0",
|
|
36
37
|
"execa": "^5.0.0",
|
|
@@ -38,20 +39,20 @@
|
|
|
38
39
|
"globby": "^11.0.2",
|
|
39
40
|
"import-fresh": "^3.2.2",
|
|
40
41
|
"js-yaml": "^4.0.0",
|
|
41
|
-
"loader-utils": "^
|
|
42
|
+
"loader-utils": "^2.0.0",
|
|
42
43
|
"lodash": "^4.17.20",
|
|
43
44
|
"remark-admonitions": "^1.2.1",
|
|
44
45
|
"shelljs": "^0.8.4",
|
|
45
|
-
"tslib": "^2.
|
|
46
|
+
"tslib": "^2.3.1",
|
|
46
47
|
"utility-types": "^3.10.0",
|
|
47
|
-
"webpack": "^5.
|
|
48
|
+
"webpack": "^5.61.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"react": "^16.8.4 || ^17.0.0",
|
|
51
52
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
52
53
|
},
|
|
53
54
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
55
|
+
"node": ">=14"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "8a491fc29ad002f90e97f5b5fe4178ac8fa0c4d7"
|
|
57
58
|
}
|
|
@@ -4,7 +4,21 @@
|
|
|
4
4
|
{
|
|
5
5
|
"type": "category",
|
|
6
6
|
"label": "foo",
|
|
7
|
-
"items": ["foo/bar", "foo/baz"]
|
|
7
|
+
"items": ["foo/bar", "foo/baz"]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "category",
|
|
11
|
+
"label": "Slugs",
|
|
12
|
+
"items": [
|
|
13
|
+
"rootAbsoluteSlug",
|
|
14
|
+
"rootRelativeSlug",
|
|
15
|
+
"rootResolvedSlug",
|
|
16
|
+
"rootTryToEscapeSlug"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "doc",
|
|
21
|
+
"id": "headingAsTitle"
|
|
8
22
|
},
|
|
9
23
|
{
|
|
10
24
|
"type": "link",
|
|
@@ -5,9 +5,11 @@ Object {
|
|
|
5
5
|
"version-1.0.0/docs": Array [
|
|
6
6
|
Object {
|
|
7
7
|
"collapsed": true,
|
|
8
|
+
"collapsible": true,
|
|
8
9
|
"items": Array [
|
|
9
10
|
Object {
|
|
10
11
|
"collapsed": true,
|
|
12
|
+
"collapsible": true,
|
|
11
13
|
"items": Array [
|
|
12
14
|
Object {
|
|
13
15
|
"id": "version-1.0.0/foo/bar",
|
|
@@ -21,6 +23,34 @@ Object {
|
|
|
21
23
|
"label": "foo",
|
|
22
24
|
"type": "category",
|
|
23
25
|
},
|
|
26
|
+
Object {
|
|
27
|
+
"collapsed": true,
|
|
28
|
+
"collapsible": true,
|
|
29
|
+
"items": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"id": "version-1.0.0/rootAbsoluteSlug",
|
|
32
|
+
"type": "doc",
|
|
33
|
+
},
|
|
34
|
+
Object {
|
|
35
|
+
"id": "version-1.0.0/rootRelativeSlug",
|
|
36
|
+
"type": "doc",
|
|
37
|
+
},
|
|
38
|
+
Object {
|
|
39
|
+
"id": "version-1.0.0/rootResolvedSlug",
|
|
40
|
+
"type": "doc",
|
|
41
|
+
},
|
|
42
|
+
Object {
|
|
43
|
+
"id": "version-1.0.0/rootTryToEscapeSlug",
|
|
44
|
+
"type": "doc",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"label": "Slugs",
|
|
48
|
+
"type": "category",
|
|
49
|
+
},
|
|
50
|
+
Object {
|
|
51
|
+
"id": "version-1.0.0/headingAsTitle",
|
|
52
|
+
"type": "doc",
|
|
53
|
+
},
|
|
24
54
|
Object {
|
|
25
55
|
"href": "https://github.com",
|
|
26
56
|
"label": "Github",
|
|
@@ -36,6 +66,7 @@ Object {
|
|
|
36
66
|
},
|
|
37
67
|
Object {
|
|
38
68
|
"collapsed": true,
|
|
69
|
+
"collapsible": true,
|
|
39
70
|
"items": Array [
|
|
40
71
|
Object {
|
|
41
72
|
"id": "version-1.0.0/hello",
|
|
@@ -54,6 +85,7 @@ Object {
|
|
|
54
85
|
"version-2.0.0/docs": Array [
|
|
55
86
|
Object {
|
|
56
87
|
"collapsed": true,
|
|
88
|
+
"collapsible": true,
|
|
57
89
|
"items": Array [
|
|
58
90
|
Object {
|
|
59
91
|
"id": "version-2.0.0/foo/bar",
|
|
@@ -65,6 +97,7 @@ Object {
|
|
|
65
97
|
},
|
|
66
98
|
Object {
|
|
67
99
|
"collapsed": true,
|
|
100
|
+
"collapsible": true,
|
|
68
101
|
"items": Array [
|
|
69
102
|
Object {
|
|
70
103
|
"id": "version-2.0.0/hello",
|