@docusaurus/plugin-content-docs 3.3.2 → 3.5.0
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 +0 -1
- package/lib/categoryGeneratedIndex.js +1 -2
- package/lib/cli.d.ts +0 -1
- package/lib/cli.js +1 -2
- package/lib/client/doc.d.ts +29 -0
- package/lib/client/doc.js +47 -0
- package/lib/client/docSidebarItemsExpandedState.d.ts +30 -0
- package/lib/client/docSidebarItemsExpandedState.js +27 -0
- package/lib/client/docsClientUtils.js +16 -8
- package/lib/client/docsPreferredVersion.d.ts +29 -0
- package/lib/client/docsPreferredVersion.js +124 -0
- package/lib/client/docsSearch.d.ts +19 -0
- package/lib/client/docsSearch.js +39 -0
- package/lib/{markdown/linkify.d.ts → client/docsSearch.test.d.ts} +1 -2
- package/lib/client/docsSearch.test.js +12 -0
- package/lib/client/docsSidebar.d.ts +25 -0
- package/lib/client/docsSidebar.js +29 -0
- package/lib/client/docsUtils.d.ts +106 -0
- package/lib/client/docsUtils.js +273 -0
- package/lib/client/docsVersion.d.ts +19 -0
- package/lib/client/docsVersion.js +25 -0
- package/lib/client/index.d.ts +8 -0
- package/lib/client/index.js +8 -0
- package/lib/docs.d.ts +2 -1
- package/lib/docs.js +17 -10
- package/lib/frontMatter.d.ts +0 -1
- package/lib/frontMatter.js +2 -2
- package/lib/globalData.js +1 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +85 -55
- package/lib/numberPrefix.d.ts +0 -1
- package/lib/numberPrefix.js +3 -3
- package/lib/options.d.ts +0 -1
- package/lib/options.js +13 -2
- package/lib/props.d.ts +0 -1
- package/lib/props.js +7 -6
- package/lib/routes.d.ts +0 -1
- package/lib/routes.js +23 -7
- package/lib/sidebars/generator.js +3 -0
- package/lib/sidebars/index.d.ts +0 -1
- package/lib/sidebars/index.js +4 -4
- package/lib/sidebars/normalization.js +2 -3
- package/lib/sidebars/postProcessor.js +1 -2
- package/lib/sidebars/processor.js +1 -2
- package/lib/sidebars/types.d.ts +1 -1
- package/lib/sidebars/utils.d.ts +0 -1
- package/lib/sidebars/utils.js +13 -14
- package/lib/sidebars/validation.js +3 -3
- package/lib/slug.d.ts +0 -1
- package/lib/slug.js +1 -1
- package/lib/translations.d.ts +0 -1
- package/lib/translations.js +2 -3
- package/lib/types.d.ts +3 -14
- package/lib/versions/files.d.ts +0 -1
- package/lib/versions/files.js +7 -8
- package/lib/versions/index.d.ts +1 -1
- package/lib/versions/index.js +15 -8
- package/lib/versions/validation.d.ts +0 -1
- package/lib/versions/validation.js +3 -4
- package/package.json +11 -10
- package/src/client/doc.tsx +71 -0
- package/src/client/docSidebarItemsExpandedState.tsx +55 -0
- package/src/client/docsClientUtils.ts +17 -8
- package/src/client/docsPreferredVersion.tsx +248 -0
- package/src/client/docsSearch.test.ts +14 -0
- package/src/client/docsSearch.ts +57 -0
- package/src/client/docsSidebar.tsx +50 -0
- package/src/client/docsUtils.tsx +415 -0
- package/src/client/docsVersion.tsx +36 -0
- package/src/client/index.ts +39 -0
- package/src/docs.ts +14 -2
- package/src/index.ts +116 -73
- package/src/options.ts +12 -0
- package/src/plugin-content-docs.d.ts +4 -3
- package/src/props.ts +2 -0
- package/src/routes.ts +23 -4
- package/src/sidebars/generator.ts +3 -0
- package/src/sidebars/postProcessor.ts +1 -0
- package/src/sidebars/types.ts +1 -0
- package/src/sidebars/validation.ts +1 -0
- package/src/types.ts +2 -16
- package/src/versions/index.ts +18 -1
- package/lib/markdown/index.d.ts +0 -9
- package/lib/markdown/index.js +0 -16
- package/lib/markdown/linkify.js +0 -34
- package/lib/tags.d.ts +0 -10
- package/lib/tags.js +0 -28
- package/src/markdown/index.ts +0 -20
- package/src/markdown/linkify.ts +0 -47
- package/src/tags.ts +0 -27
package/lib/index.js
CHANGED
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateOptions = void 0;
|
|
10
|
+
exports.default = pluginContentDocs;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
13
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
|
+
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
15
17
|
const sidebars_1 = require("./sidebars");
|
|
16
18
|
const generator_1 = require("./sidebars/generator");
|
|
17
19
|
const docs_1 = require("./docs");
|
|
@@ -22,6 +24,25 @@ const globalData_1 = require("./globalData");
|
|
|
22
24
|
const translations_1 = require("./translations");
|
|
23
25
|
const routes_1 = require("./routes");
|
|
24
26
|
const utils_2 = require("./sidebars/utils");
|
|
27
|
+
// TODO this is bad, we should have a better way to do this (new lifecycle?)
|
|
28
|
+
// The source to permalink is currently a mutable map passed to the mdx loader
|
|
29
|
+
// for link resolution
|
|
30
|
+
// see https://github.com/facebook/docusaurus/pull/10185
|
|
31
|
+
function createSourceToPermalinkHelper() {
|
|
32
|
+
const sourceToPermalink = new Map();
|
|
33
|
+
function computeSourceToPermalink(content) {
|
|
34
|
+
const allDocs = content.loadedVersions.flatMap((v) => v.docs);
|
|
35
|
+
return new Map(allDocs.map(({ source, permalink }) => [source, permalink]));
|
|
36
|
+
}
|
|
37
|
+
// Mutable map update :/
|
|
38
|
+
function update(content) {
|
|
39
|
+
sourceToPermalink.clear();
|
|
40
|
+
computeSourceToPermalink(content).forEach((value, key) => {
|
|
41
|
+
sourceToPermalink.set(key, value);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { get: () => sourceToPermalink, update };
|
|
45
|
+
}
|
|
25
46
|
async function pluginContentDocs(context, options) {
|
|
26
47
|
const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
|
|
27
48
|
// Mutate options to resolve sidebar path according to siteDir
|
|
@@ -36,6 +57,7 @@ async function pluginContentDocs(context, options) {
|
|
|
36
57
|
const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
|
|
37
58
|
// TODO env should be injected into all plugins
|
|
38
59
|
const env = process.env.NODE_ENV;
|
|
60
|
+
const sourceToPermalinkHelper = createSourceToPermalinkHelper();
|
|
39
61
|
return {
|
|
40
62
|
name: 'docusaurus-plugin-content-docs',
|
|
41
63
|
extendCli(cli) {
|
|
@@ -61,6 +83,10 @@ async function pluginContentDocs(context, options) {
|
|
|
61
83
|
function getVersionPathsToWatch(version) {
|
|
62
84
|
const result = [
|
|
63
85
|
...options.include.flatMap((pattern) => (0, utils_1.getContentPathList)(version).map((docsDirPath) => `${docsDirPath}/${pattern}`)),
|
|
86
|
+
...(0, utils_validation_1.getTagsFilePathsToWatch)({
|
|
87
|
+
contentPaths: version,
|
|
88
|
+
tags: options.tags,
|
|
89
|
+
}),
|
|
64
90
|
`${version.contentPath}/**/${generator_1.CategoryMetadataFilenamePattern}`,
|
|
65
91
|
];
|
|
66
92
|
if (typeof version.sidebarFilePath === 'string') {
|
|
@@ -71,7 +97,7 @@ async function pluginContentDocs(context, options) {
|
|
|
71
97
|
return versionsMetadata.flatMap(getVersionPathsToWatch);
|
|
72
98
|
},
|
|
73
99
|
async loadContent() {
|
|
74
|
-
async function loadVersionDocsBase(versionMetadata) {
|
|
100
|
+
async function loadVersionDocsBase(versionMetadata, tagsFile) {
|
|
75
101
|
const docFiles = await (0, docs_1.readVersionDocs)(versionMetadata, options);
|
|
76
102
|
if (docFiles.length === 0) {
|
|
77
103
|
throw new Error(`Docs version "${versionMetadata.versionName}" has no docs! At least one doc should exist at "${path_1.default.relative(siteDir, versionMetadata.contentPath)}".`);
|
|
@@ -83,12 +109,17 @@ async function pluginContentDocs(context, options) {
|
|
|
83
109
|
context,
|
|
84
110
|
options,
|
|
85
111
|
env,
|
|
112
|
+
tagsFile,
|
|
86
113
|
});
|
|
87
114
|
}
|
|
88
115
|
return Promise.all(docFiles.map(processVersionDoc));
|
|
89
116
|
}
|
|
90
117
|
async function doLoadVersion(versionMetadata) {
|
|
91
|
-
const
|
|
118
|
+
const tagsFile = await (0, utils_validation_1.getTagsFile)({
|
|
119
|
+
contentPaths: versionMetadata,
|
|
120
|
+
tags: options.tags,
|
|
121
|
+
});
|
|
122
|
+
const docsBase = await loadVersionDocsBase(versionMetadata, tagsFile);
|
|
92
123
|
// TODO we only ever need draftIds in further code, not full draft items
|
|
93
124
|
// To simplify and prevent mistakes, avoid exposing draft
|
|
94
125
|
// replace draft=>draftIds in content loaded
|
|
@@ -144,6 +175,7 @@ async function pluginContentDocs(context, options) {
|
|
|
144
175
|
return (0, translations_1.translateLoadedContent)(content, translationFiles);
|
|
145
176
|
},
|
|
146
177
|
async contentLoaded({ content, actions }) {
|
|
178
|
+
sourceToPermalinkHelper.update(content);
|
|
147
179
|
const versions = content.loadedVersions.map(versions_1.toFullVersion);
|
|
148
180
|
await (0, routes_1.createAllRoutes)({
|
|
149
181
|
baseUrl,
|
|
@@ -159,58 +191,51 @@ async function pluginContentDocs(context, options) {
|
|
|
159
191
|
});
|
|
160
192
|
},
|
|
161
193
|
configureWebpack(_config, isServer, utils, content) {
|
|
162
|
-
const { rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
194
|
+
const { rehypePlugins, remarkPlugins, recmaPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
195
|
+
const contentDirs = versionsMetadata
|
|
196
|
+
.flatMap(utils_1.getContentPathList)
|
|
197
|
+
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
198
|
+
.map(utils_1.addTrailingPathSeparator);
|
|
199
|
+
function createMDXLoader() {
|
|
200
|
+
const loaderOptions = {
|
|
201
|
+
admonitions: options.admonitions,
|
|
202
|
+
remarkPlugins,
|
|
203
|
+
rehypePlugins,
|
|
204
|
+
recmaPlugins,
|
|
205
|
+
beforeDefaultRehypePlugins,
|
|
206
|
+
beforeDefaultRemarkPlugins,
|
|
207
|
+
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
208
|
+
siteDir,
|
|
209
|
+
isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
|
|
210
|
+
metadataPath: (mdxPath) => {
|
|
211
|
+
// Note that metadataPath must be the same/in-sync as
|
|
212
|
+
// the path from createData for each MDX.
|
|
213
|
+
const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
|
|
214
|
+
return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
|
|
215
|
+
},
|
|
216
|
+
// Assets allow to convert some relative images paths to
|
|
217
|
+
// require(...) calls
|
|
218
|
+
createAssets: ({ frontMatter }) => ({
|
|
219
|
+
image: frontMatter.image,
|
|
220
|
+
}),
|
|
221
|
+
markdownConfig: siteConfig.markdown,
|
|
222
|
+
resolveMarkdownLink: ({ linkPathname, sourceFilePath }) => {
|
|
223
|
+
const version = (0, versions_1.getVersionFromSourceFilePath)(sourceFilePath, content.loadedVersions);
|
|
224
|
+
const permalink = (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
|
|
225
|
+
sourceFilePath,
|
|
226
|
+
sourceToPermalink: sourceToPermalinkHelper.get(),
|
|
227
|
+
siteDir,
|
|
228
|
+
contentPaths: version,
|
|
229
|
+
});
|
|
230
|
+
if (permalink === null) {
|
|
231
|
+
logger_1.default.report(siteConfig.onBrokenMarkdownLinks) `Docs markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath} for version number=${version.versionName}`;
|
|
232
|
+
}
|
|
233
|
+
return permalink;
|
|
234
|
+
},
|
|
235
|
+
};
|
|
180
236
|
return {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
use: [
|
|
184
|
-
{
|
|
185
|
-
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
186
|
-
options: {
|
|
187
|
-
admonitions: options.admonitions,
|
|
188
|
-
remarkPlugins,
|
|
189
|
-
rehypePlugins,
|
|
190
|
-
beforeDefaultRehypePlugins,
|
|
191
|
-
beforeDefaultRemarkPlugins,
|
|
192
|
-
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
193
|
-
siteDir,
|
|
194
|
-
isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
|
|
195
|
-
metadataPath: (mdxPath) => {
|
|
196
|
-
// Note that metadataPath must be the same/in-sync as
|
|
197
|
-
// the path from createData for each MDX.
|
|
198
|
-
const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
|
|
199
|
-
return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
|
|
200
|
-
},
|
|
201
|
-
// Assets allow to convert some relative images paths to
|
|
202
|
-
// require(...) calls
|
|
203
|
-
createAssets: ({ frontMatter, }) => ({
|
|
204
|
-
image: frontMatter.image,
|
|
205
|
-
}),
|
|
206
|
-
markdownConfig: siteConfig.markdown,
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
loader: path_1.default.resolve(__dirname, './markdown/index.js'),
|
|
211
|
-
options: docsMarkdownOptions,
|
|
212
|
-
},
|
|
213
|
-
].filter(Boolean),
|
|
237
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
238
|
+
options: loaderOptions,
|
|
214
239
|
};
|
|
215
240
|
}
|
|
216
241
|
return {
|
|
@@ -225,12 +250,17 @@ async function pluginContentDocs(context, options) {
|
|
|
225
250
|
},
|
|
226
251
|
},
|
|
227
252
|
module: {
|
|
228
|
-
rules: [
|
|
253
|
+
rules: [
|
|
254
|
+
{
|
|
255
|
+
test: /\.mdx?$/i,
|
|
256
|
+
include: contentDirs,
|
|
257
|
+
use: [createMDXLoader()],
|
|
258
|
+
},
|
|
259
|
+
],
|
|
229
260
|
},
|
|
230
261
|
};
|
|
231
262
|
},
|
|
232
263
|
};
|
|
233
264
|
}
|
|
234
|
-
exports.default = pluginContentDocs;
|
|
235
265
|
var options_1 = require("./options");
|
|
236
266
|
Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });
|
package/lib/numberPrefix.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
export declare const DefaultNumberPrefixParser: NumberPrefixParser;
|
|
10
9
|
export declare const DisabledNumberPrefixParser: NumberPrefixParser;
|
package/lib/numberPrefix.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.DisabledNumberPrefixParser = exports.DefaultNumberPrefixParser = void 0;
|
|
10
|
+
exports.stripNumberPrefix = stripNumberPrefix;
|
|
11
|
+
exports.stripPathNumberPrefixes = stripPathNumberPrefixes;
|
|
10
12
|
// Best-effort to avoid parsing some patterns as number prefix
|
|
11
13
|
// ignore common date-like patterns: https://github.com/facebook/docusaurus/issues/4640
|
|
12
14
|
// ignore common versioning patterns: https://github.com/facebook/docusaurus/issues/4653
|
|
@@ -39,7 +41,6 @@ exports.DisabledNumberPrefixParser = DisabledNumberPrefixParser;
|
|
|
39
41
|
function stripNumberPrefix(str, parser) {
|
|
40
42
|
return parser(str).filename;
|
|
41
43
|
}
|
|
42
|
-
exports.stripNumberPrefix = stripNumberPrefix;
|
|
43
44
|
// 0-myFolder/0-mySubfolder/0-myDoc => myFolder/mySubfolder/myDoc
|
|
44
45
|
function stripPathNumberPrefixes(path, parser) {
|
|
45
46
|
return path
|
|
@@ -47,4 +48,3 @@ function stripPathNumberPrefixes(path, parser) {
|
|
|
47
48
|
.map((segment) => stripNumberPrefix(segment, parser))
|
|
48
49
|
.join('/');
|
|
49
50
|
}
|
|
50
|
-
exports.stripPathNumberPrefixes = stripPathNumberPrefixes;
|
package/lib/options.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { OptionValidationContext } from '@docusaurus/types';
|
|
9
8
|
import type { PluginOptions, Options } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
export declare const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'>;
|
package/lib/options.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.DEFAULT_OPTIONS = void 0;
|
|
10
|
+
exports.validateOptions = validateOptions;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
13
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -30,6 +31,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
30
31
|
docCategoryGeneratedIndexComponent: '@theme/DocCategoryGeneratedIndexPage',
|
|
31
32
|
remarkPlugins: [],
|
|
32
33
|
rehypePlugins: [],
|
|
34
|
+
recmaPlugins: [],
|
|
33
35
|
beforeDefaultRemarkPlugins: [],
|
|
34
36
|
beforeDefaultRehypePlugins: [],
|
|
35
37
|
showLastUpdateTime: false,
|
|
@@ -44,6 +46,8 @@ exports.DEFAULT_OPTIONS = {
|
|
|
44
46
|
sidebarCollapsible: true,
|
|
45
47
|
sidebarCollapsed: true,
|
|
46
48
|
breadcrumbs: true,
|
|
49
|
+
onInlineTags: 'warn',
|
|
50
|
+
tags: undefined,
|
|
47
51
|
};
|
|
48
52
|
const VersionOptionsSchema = utils_validation_1.Joi.object({
|
|
49
53
|
path: utils_validation_1.Joi.string().allow('').optional(),
|
|
@@ -89,6 +93,7 @@ const OptionsSchema = utils_validation_1.Joi.object({
|
|
|
89
93
|
docCategoryGeneratedIndexComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docCategoryGeneratedIndexComponent),
|
|
90
94
|
remarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.remarkPlugins),
|
|
91
95
|
rehypePlugins: utils_validation_1.RehypePluginsSchema.default(exports.DEFAULT_OPTIONS.rehypePlugins),
|
|
96
|
+
recmaPlugins: utils_validation_1.RecmaPluginsSchema.default(exports.DEFAULT_OPTIONS.recmaPlugins),
|
|
92
97
|
beforeDefaultRemarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.beforeDefaultRemarkPlugins),
|
|
93
98
|
beforeDefaultRehypePlugins: utils_validation_1.RehypePluginsSchema.default(exports.DEFAULT_OPTIONS.beforeDefaultRehypePlugins),
|
|
94
99
|
admonitions: utils_validation_1.AdmonitionsSchema.default(exports.DEFAULT_OPTIONS.admonitions),
|
|
@@ -100,6 +105,13 @@ const OptionsSchema = utils_validation_1.Joi.object({
|
|
|
100
105
|
lastVersion: utils_validation_1.Joi.string().optional(),
|
|
101
106
|
versions: VersionsOptionsSchema,
|
|
102
107
|
breadcrumbs: utils_validation_1.Joi.bool().default(exports.DEFAULT_OPTIONS.breadcrumbs),
|
|
108
|
+
onInlineTags: utils_validation_1.Joi.string()
|
|
109
|
+
.equal('ignore', 'log', 'warn', 'throw')
|
|
110
|
+
.default(exports.DEFAULT_OPTIONS.onInlineTags),
|
|
111
|
+
tags: utils_validation_1.Joi.string()
|
|
112
|
+
.disallow('')
|
|
113
|
+
.allow(null, false)
|
|
114
|
+
.default(() => exports.DEFAULT_OPTIONS.tags),
|
|
103
115
|
});
|
|
104
116
|
function validateOptions({ validate, options: userOptions, }) {
|
|
105
117
|
let options = userOptions;
|
|
@@ -124,4 +136,3 @@ function validateOptions({ validate, options: userOptions, }) {
|
|
|
124
136
|
const normalizedOptions = validate(OptionsSchema, options);
|
|
125
137
|
return normalizedOptions;
|
|
126
138
|
}
|
|
127
|
-
exports.validateOptions = validateOptions;
|
package/lib/props.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { VersionTag, VersionTags } from './types';
|
|
9
8
|
import type { SidebarItemDoc } from './sidebars/types';
|
|
10
9
|
import type { PropSidebars, PropVersionMetadata, PropTagDocList, PropTagsListPage, PropSidebarItemLink, DocMetadata, LoadedVersion } from '@docusaurus/plugin-content-docs';
|
package/lib/props.js
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.toSidebarDocItemLinkProp = toSidebarDocItemLinkProp;
|
|
10
|
+
exports.toSidebarsProp = toSidebarsProp;
|
|
11
|
+
exports.toVersionMetadataProp = toVersionMetadataProp;
|
|
12
|
+
exports.toTagDocListProp = toTagDocListProp;
|
|
13
|
+
exports.toTagsListTagsProp = toTagsListTagsProp;
|
|
10
14
|
const tslib_1 = require("tslib");
|
|
11
15
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
16
|
const docs_1 = require("./docs");
|
|
@@ -22,7 +26,6 @@ function toSidebarDocItemLinkProp({ item, doc, }) {
|
|
|
22
26
|
unlisted,
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
|
-
exports.toSidebarDocItemLinkProp = toSidebarDocItemLinkProp;
|
|
26
29
|
function toSidebarsProp(loadedVersion) {
|
|
27
30
|
const docsById = (0, docs_1.createDocsByIdIndex)(loadedVersion.docs);
|
|
28
31
|
function getDocById(docId) {
|
|
@@ -92,7 +95,6 @@ Available document ids are:
|
|
|
92
95
|
// This is what will be passed as props to the UI component.
|
|
93
96
|
return lodash_1.default.mapValues(loadedVersion.sidebars, (items) => items.map(normalizeItem));
|
|
94
97
|
}
|
|
95
|
-
exports.toSidebarsProp = toSidebarsProp;
|
|
96
98
|
function toVersionDocsProp(loadedVersion) {
|
|
97
99
|
return Object.fromEntries(loadedVersion.docs.map((doc) => [
|
|
98
100
|
doc.id,
|
|
@@ -118,7 +120,6 @@ function toVersionMetadataProp(pluginId, loadedVersion) {
|
|
|
118
120
|
docs: toVersionDocsProp(loadedVersion),
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
|
-
exports.toVersionMetadataProp = toVersionMetadataProp;
|
|
122
123
|
function toTagDocListProp({ allTagsPath, tag, docs, }) {
|
|
123
124
|
function toDocListProp() {
|
|
124
125
|
const list = lodash_1.default.compact(tag.docIds.map((id) => docs.find((doc) => doc.id === id)));
|
|
@@ -134,20 +135,20 @@ function toTagDocListProp({ allTagsPath, tag, docs, }) {
|
|
|
134
135
|
return {
|
|
135
136
|
label: tag.label,
|
|
136
137
|
permalink: tag.permalink,
|
|
138
|
+
description: tag.description,
|
|
137
139
|
allTagsPath,
|
|
138
140
|
count: tag.docIds.length,
|
|
139
141
|
items: toDocListProp(),
|
|
140
142
|
unlisted: tag.unlisted,
|
|
141
143
|
};
|
|
142
144
|
}
|
|
143
|
-
exports.toTagDocListProp = toTagDocListProp;
|
|
144
145
|
function toTagsListTagsProp(versionTags) {
|
|
145
146
|
return Object.values(versionTags)
|
|
146
147
|
.filter((tagValue) => !tagValue.unlisted)
|
|
147
148
|
.map((tagValue) => ({
|
|
148
149
|
label: tagValue.label,
|
|
149
150
|
permalink: tagValue.permalink,
|
|
151
|
+
description: tagValue.description,
|
|
150
152
|
count: tagValue.docIds.length,
|
|
151
153
|
}));
|
|
152
154
|
}
|
|
153
|
-
exports.toTagsListTagsProp = toTagsListTagsProp;
|
package/lib/routes.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
|
|
9
8
|
import type { FullVersion } from './types';
|
|
10
9
|
import type { PluginOptions } from '@docusaurus/plugin-content-docs';
|
package/lib/routes.js
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.buildAllRoutes = buildAllRoutes;
|
|
10
|
+
exports.createAllRoutes = createAllRoutes;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
14
|
const utils_1 = require("@docusaurus/utils");
|
|
14
15
|
const props_1 = require("./props");
|
|
15
|
-
const tags_1 = require("./tags");
|
|
16
16
|
function createDocRouteMetadata(docMeta) {
|
|
17
17
|
return {
|
|
18
18
|
sourceFilePath: (0, utils_1.aliasedSitePathToRelativePath)(docMeta.source),
|
|
@@ -74,12 +74,30 @@ async function buildVersionSidebarRoute(param) {
|
|
|
74
74
|
routes: subRoutes,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
function getVersionTags(docs) {
|
|
78
|
+
const groups = (0, utils_1.groupTaggedItems)(docs, (doc) => doc.tags);
|
|
79
|
+
return lodash_1.default.mapValues(groups, ({ tag, items: tagDocs }) => {
|
|
80
|
+
const tagVisibility = (0, utils_1.getTagVisibility)({
|
|
81
|
+
items: tagDocs,
|
|
82
|
+
isUnlisted: (item) => item.unlisted,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
inline: tag.inline,
|
|
86
|
+
label: tag.label,
|
|
87
|
+
permalink: tag.permalink,
|
|
88
|
+
description: tag.description,
|
|
89
|
+
docIds: tagVisibility.listedItems.map((item) => item.id),
|
|
90
|
+
unlisted: tagVisibility.unlisted,
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
77
94
|
async function buildVersionTagsRoutes(param) {
|
|
78
95
|
const { version, options } = param;
|
|
79
|
-
const versionTags =
|
|
96
|
+
const versionTags = getVersionTags(version.docs);
|
|
80
97
|
async function buildTagsListRoute() {
|
|
98
|
+
const tags = (0, props_1.toTagsListTagsProp)(versionTags);
|
|
81
99
|
// Don't create a tags list page if there's no tag
|
|
82
|
-
if (
|
|
100
|
+
if (tags.length === 0) {
|
|
83
101
|
return null;
|
|
84
102
|
}
|
|
85
103
|
return {
|
|
@@ -87,7 +105,7 @@ async function buildVersionTagsRoutes(param) {
|
|
|
87
105
|
exact: true,
|
|
88
106
|
component: options.docTagsListComponent,
|
|
89
107
|
props: {
|
|
90
|
-
tags
|
|
108
|
+
tags,
|
|
91
109
|
},
|
|
92
110
|
};
|
|
93
111
|
}
|
|
@@ -160,9 +178,7 @@ async function buildAllRoutes(param) {
|
|
|
160
178
|
},
|
|
161
179
|
];
|
|
162
180
|
}
|
|
163
|
-
exports.buildAllRoutes = buildAllRoutes;
|
|
164
181
|
async function createAllRoutes(param) {
|
|
165
182
|
const routes = await buildAllRoutes(param);
|
|
166
183
|
routes.forEach(param.actions.addRoute);
|
|
167
184
|
}
|
|
168
|
-
exports.createAllRoutes = createAllRoutes;
|
|
@@ -168,6 +168,9 @@ Available doc IDs:
|
|
|
168
168
|
...(customProps !== undefined && { customProps }),
|
|
169
169
|
...(className !== undefined && { className }),
|
|
170
170
|
items,
|
|
171
|
+
...(categoryMetadata?.description && {
|
|
172
|
+
description: categoryMetadata?.description,
|
|
173
|
+
}),
|
|
171
174
|
...(link && { link }),
|
|
172
175
|
};
|
|
173
176
|
}
|
package/lib/sidebars/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { PluginOptions } from '@docusaurus/plugin-content-docs';
|
|
9
8
|
import type { SidebarsConfig, Sidebars, SidebarProcessorParams } from './types';
|
|
10
9
|
export declare const DefaultSidebars: SidebarsConfig;
|
package/lib/sidebars/index.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.DisabledSidebars = exports.DefaultSidebars = void 0;
|
|
10
|
+
exports.resolveSidebarPathOption = resolveSidebarPathOption;
|
|
11
|
+
exports.loadSidebarsFile = loadSidebarsFile;
|
|
12
|
+
exports.loadSidebars = loadSidebars;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
15
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -34,7 +37,6 @@ function resolveSidebarPathOption(siteDir, sidebarPathOption) {
|
|
|
34
37
|
? path_1.default.resolve(siteDir, sidebarPathOption)
|
|
35
38
|
: sidebarPathOption;
|
|
36
39
|
}
|
|
37
|
-
exports.resolveSidebarPathOption = resolveSidebarPathOption;
|
|
38
40
|
async function readCategoriesMetadata(contentPath) {
|
|
39
41
|
const categoryFiles = await (0, utils_1.Globby)('**/_category_.{json,yml,yaml}', {
|
|
40
42
|
cwd: contentPath,
|
|
@@ -80,7 +82,6 @@ async function loadSidebarsFile(sidebarFilePath) {
|
|
|
80
82
|
// TODO unsafe, need to refactor and improve validation
|
|
81
83
|
return sidebars;
|
|
82
84
|
}
|
|
83
|
-
exports.loadSidebarsFile = loadSidebarsFile;
|
|
84
85
|
async function loadSidebars(sidebarFilePath, options) {
|
|
85
86
|
try {
|
|
86
87
|
const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
|
|
@@ -95,4 +96,3 @@ async function loadSidebars(sidebarFilePath, options) {
|
|
|
95
96
|
throw err;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
exports.loadSidebars = loadSidebars;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.normalizeItem = normalizeItem;
|
|
10
|
+
exports.normalizeSidebars = normalizeSidebars;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -43,7 +44,6 @@ function normalizeItem(item) {
|
|
|
43
44
|
}
|
|
44
45
|
return [item];
|
|
45
46
|
}
|
|
46
|
-
exports.normalizeItem = normalizeItem;
|
|
47
47
|
function normalizeSidebar(sidebar, place) {
|
|
48
48
|
if (!Array.isArray(sidebar) && !(0, utils_1.isCategoriesShorthand)(sidebar)) {
|
|
49
49
|
throw new Error(logger_1.default.interpolate `Invalid sidebar items collection code=${JSON.stringify(sidebar)} in ${place}: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a code=${'type'} property). See url=${'https://docusaurus.io/docs/sidebar/items'} for all valid syntaxes.`);
|
|
@@ -56,4 +56,3 @@ function normalizeSidebar(sidebar, place) {
|
|
|
56
56
|
function normalizeSidebars(sidebars) {
|
|
57
57
|
return lodash_1.default.mapValues(sidebars, (sidebar, id) => normalizeSidebar(sidebar, logger_1.default.interpolate `sidebar name=${id}`));
|
|
58
58
|
}
|
|
59
|
-
exports.normalizeSidebars = normalizeSidebars;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.postProcessSidebars =
|
|
9
|
+
exports.postProcessSidebars = postProcessSidebars;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -77,4 +77,3 @@ function postProcessSidebars(sidebars, params) {
|
|
|
77
77
|
.map((item) => postProcessSidebarItem(item, { ...params, draftIds }))
|
|
78
78
|
.filter((v) => Boolean(v)));
|
|
79
79
|
}
|
|
80
|
-
exports.postProcessSidebars = postProcessSidebars;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.processSidebars =
|
|
9
|
+
exports.processSidebars = processSidebars;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
@@ -75,4 +75,3 @@ async function processSidebars(unprocessedSidebars, categoriesMetadata, params)
|
|
|
75
75
|
(0, validation_1.validateSidebars)(processedSidebars);
|
|
76
76
|
return processedSidebars;
|
|
77
77
|
}
|
|
78
|
-
exports.processSidebars = processSidebars;
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { Optional, Required } from 'utility-types';
|
|
9
8
|
import type { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher, DocMetadataBase, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
import type { Slugger } from '@docusaurus/utils';
|
|
@@ -139,6 +138,7 @@ export type PropSidebarBreadcrumbsItem = PropSidebarItemLink | PropSidebarItemCa
|
|
|
139
138
|
export type CategoryMetadataFile = {
|
|
140
139
|
label?: string;
|
|
141
140
|
position?: number;
|
|
141
|
+
description?: string;
|
|
142
142
|
collapsed?: boolean;
|
|
143
143
|
collapsible?: boolean;
|
|
144
144
|
className?: string;
|
package/lib/sidebars/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../../src/plugin-content-docs.d.ts" />
|
|
8
7
|
import type { Sidebars, Sidebar, SidebarItem, SidebarItemCategory, SidebarItemLink, SidebarItemDoc, SidebarCategoriesShorthand, SidebarItemConfig, SidebarItemCategoryWithGeneratedIndex, SidebarNavigationItem } from './types';
|
|
9
8
|
import type { DocMetadataBase, PropNavigationLink, VersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
10
9
|
export declare function isCategoriesShorthand(item: SidebarItemConfig): item is SidebarCategoriesShorthand;
|