@docusaurus/plugin-content-docs 0.0.0-4523 → 0.0.0-4524
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/cli.js +4 -2
- package/lib/client/docsClientUtils.js +2 -2
- package/lib/client/globalDataHooks.js +4 -3
- package/lib/docs.d.ts +2 -1
- package/lib/docs.js +17 -15
- package/lib/numberPrefix.js +5 -4
- package/lib/options.js +3 -2
- package/lib/routes.js +4 -2
- package/lib/sidebars/generator.js +20 -17
- package/lib/sidebars/processor.js +6 -3
- package/lib/sidebars/utils.js +46 -54
- package/lib/sidebars/validation.js +6 -3
- package/lib/slug.js +6 -8
- package/lib/translations.js +7 -7
- package/lib/versions.js +11 -21
- package/package.json +9 -9
- package/src/cli.ts +4 -2
- package/src/client/docsClientUtils.ts +2 -2
- package/src/client/globalDataHooks.ts +4 -3
- package/src/docs.ts +17 -13
- package/src/numberPrefix.ts +5 -4
- package/src/options.ts +3 -2
- package/src/plugin-content-docs.d.ts +2 -1
- package/src/routes.ts +4 -2
- package/src/sidebars/generator.ts +25 -19
- package/src/sidebars/processor.ts +6 -3
- package/src/sidebars/types.ts +2 -1
- package/src/sidebars/utils.ts +57 -61
- package/src/sidebars/validation.ts +6 -3
- package/src/slug.ts +9 -10
- package/src/translations.ts +7 -6
- package/src/versions.ts +13 -19
package/src/translations.ts
CHANGED
|
@@ -31,11 +31,10 @@ import {CURRENT_VERSION_NAME} from './constants';
|
|
|
31
31
|
function getVersionFileName(versionName: string): string {
|
|
32
32
|
if (versionName === CURRENT_VERSION_NAME) {
|
|
33
33
|
return versionName;
|
|
34
|
-
} else {
|
|
35
|
-
// I don't like this "version-" prefix,
|
|
36
|
-
// but it's for consistency with site/versioned_docs
|
|
37
|
-
return `version-${versionName}`;
|
|
38
34
|
}
|
|
35
|
+
// I don't like this "version-" prefix,
|
|
36
|
+
// but it's for consistency with site/versioned_docs
|
|
37
|
+
return `version-${versionName}`;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// TODO legacy, the sidebar name is like "version-2.0.0-alpha.66/docs"
|
|
@@ -68,7 +67,8 @@ function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
|
68
67
|
? {
|
|
69
68
|
[`${doc.unversionedId}.sidebar_label`]: {
|
|
70
69
|
message: doc.sidebar_label,
|
|
71
|
-
description:
|
|
70
|
+
description:
|
|
71
|
+
`The sidebar label for doc with id=${doc.unversionedId}`,
|
|
72
72
|
},
|
|
73
73
|
}
|
|
74
74
|
: undefined),
|
|
@@ -253,7 +253,8 @@ function getVersionTranslationFiles(version: LoadedVersion): TranslationFiles {
|
|
|
253
253
|
const sidebarsTranslations: TranslationFileContent =
|
|
254
254
|
getSidebarsTranslations(version);
|
|
255
255
|
|
|
256
|
-
// const docsTranslations: TranslationFileContent =
|
|
256
|
+
// const docsTranslations: TranslationFileContent =
|
|
257
|
+
// getDocsTranslations(version);
|
|
257
258
|
|
|
258
259
|
return [
|
|
259
260
|
{
|
package/src/versions.ts
CHANGED
|
@@ -33,11 +33,9 @@ import {resolveSidebarPathOption} from './sidebars';
|
|
|
33
33
|
|
|
34
34
|
// retro-compatibility: no prefix for the default plugin id
|
|
35
35
|
function addPluginIdPrefix(fileOrDir: string, pluginId: string): string {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return `${pluginId}_${fileOrDir}`;
|
|
40
|
-
}
|
|
36
|
+
return pluginId === DEFAULT_PLUGIN_ID
|
|
37
|
+
? fileOrDir
|
|
38
|
+
: `${pluginId}_${fileOrDir}`;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
export function getVersionedDocsDirPath(
|
|
@@ -96,9 +94,8 @@ async function readVersionsFile(
|
|
|
96
94
|
const content = JSON.parse(await fs.readFile(versionsFilePath, 'utf8'));
|
|
97
95
|
ensureValidVersionArray(content);
|
|
98
96
|
return content;
|
|
99
|
-
} else {
|
|
100
|
-
return null;
|
|
101
97
|
}
|
|
98
|
+
return null;
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
async function readVersionNames(
|
|
@@ -274,15 +271,13 @@ function getDefaultVersionBanner({
|
|
|
274
271
|
return null;
|
|
275
272
|
}
|
|
276
273
|
// Upcoming versions: unreleased banner
|
|
277
|
-
|
|
274
|
+
if (
|
|
278
275
|
versionNames.indexOf(versionName) < versionNames.indexOf(lastVersionName)
|
|
279
276
|
) {
|
|
280
277
|
return 'unreleased';
|
|
281
278
|
}
|
|
282
279
|
// Older versions: display unmaintained banner
|
|
283
|
-
|
|
284
|
-
return 'unmaintained';
|
|
285
|
-
}
|
|
280
|
+
return 'unmaintained';
|
|
286
281
|
}
|
|
287
282
|
|
|
288
283
|
function getVersionBanner({
|
|
@@ -443,8 +438,9 @@ function checkVersionMetadataPaths({
|
|
|
443
438
|
);
|
|
444
439
|
}
|
|
445
440
|
|
|
446
|
-
// If the current version defines a path to a sidebar file
|
|
447
|
-
// Note: for versioned sidebars, the file may not exist (as
|
|
441
|
+
// If the current version defines a path to a sidebar file that does not
|
|
442
|
+
// exist, we throw! Note: for versioned sidebars, the file may not exist (as
|
|
443
|
+
// we prefer to not create it rather than to create an empty file)
|
|
448
444
|
// See https://github.com/facebook/docusaurus/issues/3366
|
|
449
445
|
// See https://github.com/facebook/docusaurus/pull/4775
|
|
450
446
|
if (
|
|
@@ -469,11 +465,10 @@ Please set the docs "sidebarPath" field in your config file to:
|
|
|
469
465
|
function getDefaultLastVersionName(versionNames: string[]) {
|
|
470
466
|
if (versionNames.length === 1) {
|
|
471
467
|
return versionNames[0];
|
|
472
|
-
} else {
|
|
473
|
-
return versionNames.filter(
|
|
474
|
-
(versionName) => versionName !== CURRENT_VERSION_NAME,
|
|
475
|
-
)[0];
|
|
476
468
|
}
|
|
469
|
+
return versionNames.filter(
|
|
470
|
+
(versionName) => versionName !== CURRENT_VERSION_NAME,
|
|
471
|
+
)[0];
|
|
477
472
|
}
|
|
478
473
|
|
|
479
474
|
function checkVersionsOptions(
|
|
@@ -544,9 +539,8 @@ function filterVersions(
|
|
|
544
539
|
return versionNamesUnfiltered.filter((name) =>
|
|
545
540
|
(options.onlyIncludeVersions || []).includes(name),
|
|
546
541
|
);
|
|
547
|
-
} else {
|
|
548
|
-
return versionNamesUnfiltered;
|
|
549
542
|
}
|
|
543
|
+
return versionNamesUnfiltered;
|
|
550
544
|
}
|
|
551
545
|
|
|
552
546
|
export async function readVersionsMetadata({
|