@docusaurus/plugin-content-docs 0.0.0-5044 → 0.0.0-5047
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/client/docsClientUtils.js +1 -1
- package/lib/index.js +1 -1
- package/lib/markdown/index.js +1 -1
- package/lib/props.js +1 -1
- package/lib/sidebars/generator.js +1 -1
- package/lib/sidebars/postProcessor.js +1 -1
- package/lib/sidebars/types.d.ts +2 -2
- package/lib/sidebars/utils.js +1 -1
- package/lib/sidebars/validation.js +5 -1
- package/lib/slug.js +1 -1
- package/lib/versions/validation.js +1 -1
- package/package.json +9 -9
- package/src/client/docsClientUtils.ts +1 -1
- package/src/client/index.ts +5 -3
- package/src/index.ts +1 -1
- package/src/markdown/index.ts +1 -1
- package/src/options.ts +1 -1
- package/src/props.ts +1 -1
- package/src/sidebars/generator.ts +1 -1
- package/src/sidebars/postProcessor.ts +1 -1
- package/src/sidebars/types.ts +2 -2
- package/src/sidebars/utils.ts +1 -1
- package/src/sidebars/validation.ts +6 -2
- package/src/slug.ts +1 -1
- package/src/versions/validation.ts +3 -1
|
@@ -73,6 +73,6 @@ export function getActiveDocContext(data, pathname) {
|
|
|
73
73
|
export function getDocVersionSuggestions(data, pathname) {
|
|
74
74
|
const latestVersion = getLatestVersion(data);
|
|
75
75
|
const activeDocContext = getActiveDocContext(data, pathname);
|
|
76
|
-
const latestDocSuggestion = activeDocContext
|
|
76
|
+
const latestDocSuggestion = activeDocContext.alternateDocVersions[latestVersion.name];
|
|
77
77
|
return { latestDocSuggestion, latestVersionSuggestion: latestVersion };
|
|
78
78
|
}
|
package/lib/index.js
CHANGED
|
@@ -76,7 +76,7 @@ async function pluginContentDocs(context, options) {
|
|
|
76
76
|
if (docFiles.length === 0) {
|
|
77
77
|
throw new Error(`Docs version "${versionMetadata.versionName}" has no docs! At least one doc should exist at "${path_1.default.relative(siteDir, versionMetadata.contentPath)}".`);
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
function processVersionDoc(docFile) {
|
|
80
80
|
return (0, docs_1.processDocMetadata)({
|
|
81
81
|
docFile,
|
|
82
82
|
versionMetadata,
|
package/lib/markdown/index.js
CHANGED
|
@@ -11,6 +11,6 @@ function markdownLoader(source) {
|
|
|
11
11
|
const fileString = source;
|
|
12
12
|
const callback = this.async();
|
|
13
13
|
const options = this.getOptions();
|
|
14
|
-
return callback
|
|
14
|
+
return callback(null, (0, linkify_1.linkify)(fileString, this.resourcePath, options));
|
|
15
15
|
}
|
|
16
16
|
exports.default = markdownLoader;
|
package/lib/props.js
CHANGED
|
@@ -26,7 +26,7 @@ Available document ids are:
|
|
|
26
26
|
const { title, permalink, frontMatter: { sidebar_label: sidebarLabel }, } = docMetadata;
|
|
27
27
|
return {
|
|
28
28
|
type: 'link',
|
|
29
|
-
label: sidebarLabel
|
|
29
|
+
label: sidebarLabel ?? item.label ?? title,
|
|
30
30
|
href: permalink,
|
|
31
31
|
className: item.className,
|
|
32
32
|
customProps: item.customProps ?? docMetadata.frontMatter.sidebar_custom_props,
|
|
@@ -21,7 +21,7 @@ function getLocalDocId(docId) {
|
|
|
21
21
|
exports.CategoryMetadataFilenameBase = '_category_';
|
|
22
22
|
exports.CategoryMetadataFilenamePattern = '_category_.{json,yml,yaml}';
|
|
23
23
|
// Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
|
|
24
|
-
const DefaultSidebarItemsGenerator =
|
|
24
|
+
const DefaultSidebarItemsGenerator = ({ numberPrefixParser, isCategoryIndex, docs: allDocs, item: { dirName: autogenDir }, categoriesMetadata, }) => {
|
|
25
25
|
const docsById = (0, docs_1.createDocsByIdIndex)(allDocs);
|
|
26
26
|
const findDoc = (docId) => docsById[docId];
|
|
27
27
|
const getDoc = (docId) => {
|
package/lib/sidebars/types.d.ts
CHANGED
|
@@ -157,7 +157,7 @@ export declare type SidebarItemsGeneratorArgs = {
|
|
|
157
157
|
[filePath: string]: CategoryMetadataFile;
|
|
158
158
|
};
|
|
159
159
|
};
|
|
160
|
-
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<NormalizedSidebar>;
|
|
160
|
+
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => NormalizedSidebar | Promise<NormalizedSidebar>;
|
|
161
161
|
export declare type SidebarItemsGeneratorOption = (generatorArgs: {
|
|
162
162
|
/**
|
|
163
163
|
* Useful to re-use/enhance the default sidebar generation logic from
|
|
@@ -165,7 +165,7 @@ export declare type SidebarItemsGeneratorOption = (generatorArgs: {
|
|
|
165
165
|
* @see https://github.com/facebook/docusaurus/issues/4640#issuecomment-822292320
|
|
166
166
|
*/
|
|
167
167
|
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
|
168
|
-
} & SidebarItemsGeneratorArgs) => Promise<
|
|
168
|
+
} & SidebarItemsGeneratorArgs) => NormalizedSidebar | Promise<NormalizedSidebar>;
|
|
169
169
|
export declare type SidebarProcessorParams = {
|
|
170
170
|
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
|
171
171
|
numberPrefixParser: NumberPrefixParser;
|
package/lib/sidebars/utils.js
CHANGED
|
@@ -158,7 +158,7 @@ function createSidebarsUtils(sidebars) {
|
|
|
158
158
|
function getCategoryGeneratedIndexNavigation(categoryGeneratedIndexPermalink) {
|
|
159
159
|
function isCurrentCategoryGeneratedIndexItem(item) {
|
|
160
160
|
return (item.type === 'category' &&
|
|
161
|
-
item.link
|
|
161
|
+
item.link.type === 'generated-index' &&
|
|
162
162
|
item.link.permalink === categoryGeneratedIndexPermalink);
|
|
163
163
|
}
|
|
164
164
|
const sidebarName = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))[0];
|
|
@@ -133,6 +133,10 @@ const categoryMetadataFileSchema = utils_validation_1.Joi.object({
|
|
|
133
133
|
customProps: utils_validation_1.Joi.object().unknown(),
|
|
134
134
|
});
|
|
135
135
|
function validateCategoryMetadataFile(unsafeContent) {
|
|
136
|
-
|
|
136
|
+
const { error, value } = categoryMetadataFileSchema.validate(unsafeContent);
|
|
137
|
+
if (error) {
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
137
141
|
}
|
|
138
142
|
exports.validateCategoryMetadataFile = validateCategoryMetadataFile;
|
package/lib/slug.js
CHANGED
|
@@ -28,7 +28,7 @@ function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumbe
|
|
|
28
28
|
(0, docs_1.isCategoryIndex)((0, docs_1.toCategoryIndexMatcherParam)({ source, sourceDirName }))) {
|
|
29
29
|
return dirNameSlug;
|
|
30
30
|
}
|
|
31
|
-
const baseSlug = frontMatterSlug
|
|
31
|
+
const baseSlug = frontMatterSlug ?? baseID;
|
|
32
32
|
return (0, utils_1.resolvePathname)(baseSlug, getDirNameSlug());
|
|
33
33
|
}
|
|
34
34
|
function ensureValidSlug(slug) {
|
|
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
function validateVersionName(name) {
|
|
13
13
|
if (typeof name !== 'string') {
|
|
14
|
-
throw new Error(`Versions should be strings. Found type "${typeof name}" for version
|
|
14
|
+
throw new Error(`Versions should be strings. Found type "${typeof name}" for version ${JSON.stringify(name)}.`);
|
|
15
15
|
}
|
|
16
16
|
if (!name.trim()) {
|
|
17
17
|
throw new Error(`Invalid version name "${name}": version name must contain at least one non-whitespace character.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5047",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@docusaurus/core": "0.0.0-
|
|
29
|
-
"@docusaurus/logger": "0.0.0-
|
|
30
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
31
|
-
"@docusaurus/utils": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
28
|
+
"@docusaurus/core": "0.0.0-5047",
|
|
29
|
+
"@docusaurus/logger": "0.0.0-5047",
|
|
30
|
+
"@docusaurus/mdx-loader": "0.0.0-5047",
|
|
31
|
+
"@docusaurus/utils": "0.0.0-5047",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-5047",
|
|
33
33
|
"combine-promises": "^1.1.0",
|
|
34
34
|
"fs-extra": "^10.1.0",
|
|
35
35
|
"import-fresh": "^3.3.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"webpack": "^5.72.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
45
|
-
"@docusaurus/types": "0.0.0-
|
|
44
|
+
"@docusaurus/module-type-aliases": "0.0.0-5047",
|
|
45
|
+
"@docusaurus/types": "0.0.0-5047",
|
|
46
46
|
"@types/js-yaml": "^4.0.5",
|
|
47
47
|
"@types/picomatch": "^2.3.0",
|
|
48
48
|
"commander": "^5.1.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=14"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "67ac297469d98ac3eb8482d8636aee4648586f33"
|
|
62
62
|
}
|
|
@@ -126,6 +126,6 @@ export function getDocVersionSuggestions(
|
|
|
126
126
|
const latestVersion = getLatestVersion(data);
|
|
127
127
|
const activeDocContext = getActiveDocContext(data, pathname);
|
|
128
128
|
const latestDocSuggestion: GlobalDoc | undefined =
|
|
129
|
-
activeDocContext
|
|
129
|
+
activeDocContext.alternateDocVersions[latestVersion.name];
|
|
130
130
|
return {latestDocSuggestion, latestVersionSuggestion: latestVersion};
|
|
131
131
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -34,9 +34,11 @@ const StableEmptyObject = {};
|
|
|
34
34
|
// In blog-only mode, docs hooks are still used by the theme. We need a fail-
|
|
35
35
|
// safe fallback when the docs plugin is not in use
|
|
36
36
|
export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
|
|
37
|
-
(useAllPluginInstancesData('docusaurus-plugin-content-docs') as
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
(useAllPluginInstancesData('docusaurus-plugin-content-docs') as
|
|
38
|
+
| {
|
|
39
|
+
[pluginId: string]: GlobalPluginData;
|
|
40
|
+
}
|
|
41
|
+
| undefined) ?? StableEmptyObject;
|
|
40
42
|
|
|
41
43
|
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
|
42
44
|
usePluginData('docusaurus-plugin-content-docs', pluginId, {
|
package/src/index.ts
CHANGED
package/src/markdown/index.ts
CHANGED
|
@@ -16,5 +16,5 @@ export default function markdownLoader(
|
|
|
16
16
|
const fileString = source;
|
|
17
17
|
const callback = this.async();
|
|
18
18
|
const options = this.getOptions();
|
|
19
|
-
return callback
|
|
19
|
+
return callback(null, linkify(fileString, this.resourcePath, options));
|
|
20
20
|
}
|
package/src/options.ts
CHANGED
|
@@ -165,7 +165,7 @@ export function validateOptions({
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
const normalizedOptions = validate(OptionsSchema, options)
|
|
168
|
+
const normalizedOptions = validate(OptionsSchema, options);
|
|
169
169
|
|
|
170
170
|
if (normalizedOptions.admonitions) {
|
|
171
171
|
normalizedOptions.remarkPlugins = normalizedOptions.remarkPlugins.concat([
|
package/src/props.ts
CHANGED
|
@@ -46,7 +46,7 @@ type Dir = {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
|
|
49
|
-
export const DefaultSidebarItemsGenerator: SidebarItemsGenerator =
|
|
49
|
+
export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = ({
|
|
50
50
|
numberPrefixParser,
|
|
51
51
|
isCategoryIndex,
|
|
52
52
|
docs: allDocs,
|
package/src/sidebars/types.ts
CHANGED
|
@@ -251,7 +251,7 @@ export type SidebarItemsGeneratorArgs = {
|
|
|
251
251
|
};
|
|
252
252
|
export type SidebarItemsGenerator = (
|
|
253
253
|
generatorArgs: SidebarItemsGeneratorArgs,
|
|
254
|
-
) => Promise<NormalizedSidebar>;
|
|
254
|
+
) => NormalizedSidebar | Promise<NormalizedSidebar>;
|
|
255
255
|
|
|
256
256
|
export type SidebarItemsGeneratorOption = (
|
|
257
257
|
generatorArgs: {
|
|
@@ -262,7 +262,7 @@ export type SidebarItemsGeneratorOption = (
|
|
|
262
262
|
*/
|
|
263
263
|
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
|
264
264
|
} & SidebarItemsGeneratorArgs,
|
|
265
|
-
) => Promise<
|
|
265
|
+
) => NormalizedSidebar | Promise<NormalizedSidebar>;
|
|
266
266
|
|
|
267
267
|
export type SidebarProcessorParams = {
|
|
268
268
|
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
package/src/sidebars/utils.ts
CHANGED
|
@@ -257,7 +257,7 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|
|
257
257
|
): boolean {
|
|
258
258
|
return (
|
|
259
259
|
item.type === 'category' &&
|
|
260
|
-
item.link
|
|
260
|
+
item.link.type === 'generated-index' &&
|
|
261
261
|
item.link.permalink === categoryGeneratedIndexPermalink
|
|
262
262
|
);
|
|
263
263
|
}
|
|
@@ -144,7 +144,7 @@ function validateSidebarItem(
|
|
|
144
144
|
// manually
|
|
145
145
|
Joi.assert(item, sidebarItemSchema);
|
|
146
146
|
|
|
147
|
-
if ((item as
|
|
147
|
+
if ((item as NormalizedSidebarItem).type === 'category') {
|
|
148
148
|
(item as NormalizedSidebarItemCategory).items.forEach(validateSidebarItem);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -170,5 +170,9 @@ const categoryMetadataFileSchema = Joi.object<CategoryMetadataFile>({
|
|
|
170
170
|
export function validateCategoryMetadataFile(
|
|
171
171
|
unsafeContent: unknown,
|
|
172
172
|
): CategoryMetadataFile {
|
|
173
|
-
|
|
173
|
+
const {error, value} = categoryMetadataFileSchema.validate(unsafeContent);
|
|
174
|
+
if (error) {
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
return value;
|
|
174
178
|
}
|
package/src/slug.ts
CHANGED
|
@@ -11,7 +11,9 @@ import type {VersionsOptions} from '@docusaurus/plugin-content-docs';
|
|
|
11
11
|
export function validateVersionName(name: unknown): asserts name is string {
|
|
12
12
|
if (typeof name !== 'string') {
|
|
13
13
|
throw new Error(
|
|
14
|
-
`Versions should be strings. Found type "${typeof name}" for version
|
|
14
|
+
`Versions should be strings. Found type "${typeof name}" for version ${JSON.stringify(
|
|
15
|
+
name,
|
|
16
|
+
)}.`,
|
|
15
17
|
);
|
|
16
18
|
}
|
|
17
19
|
if (!name.trim()) {
|