@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.
@@ -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: `The sidebar label for doc with id=${doc.unversionedId}`,
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 = getDocsTranslations(version);
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
- if (pluginId === DEFAULT_PLUGIN_ID) {
37
- return fileOrDir;
38
- } else {
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
- else if (
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
- else {
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 that does not exist, we throw!
447
- // Note: for versioned sidebars, the file may not exist (as we prefer to not create it rather than to create an empty file)
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({