@docusaurus/plugin-content-docs 0.0.0-4426 → 0.0.0-4430

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.
@@ -41,15 +41,8 @@ async function readCategoryMetadataFile(categoryDirPath) {
41
41
  throw e;
42
42
  }
43
43
  }
44
- // eslint-disable-next-line no-restricted-syntax
45
- for (const ext of ['.json', '.yml', '.yaml']) {
46
- // Simpler to use only posix paths for mocking file metadata in tests
47
- const filePath = (0, utils_1.posixPath)(path_1.default.join(categoryDirPath, `${exports.CategoryMetadataFilenameBase}${ext}`));
48
- if (await fs_extra_1.default.pathExists(filePath)) {
49
- return tryReadFile(filePath);
50
- }
51
- }
52
- return null;
44
+ const filePath = await (0, utils_1.findAsyncSequential)(['.json', '.yml', '.yaml'].map((ext) => (0, utils_1.posixPath)(path_1.default.join(categoryDirPath, `${exports.CategoryMetadataFilenameBase}${ext}`))), fs_extra_1.default.pathExists);
45
+ return filePath ? tryReadFile(filePath) : null;
53
46
  }
54
47
  // Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
55
48
  const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, docs: allDocs, options, item: { dirName: autogenDir }, version, }) => {
@@ -101,13 +94,12 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, docs: allDocs,
101
94
  docs.forEach((doc) => {
102
95
  const breadcrumb = getRelativeBreadcrumb(doc);
103
96
  let currentDir = treeRoot; // We walk down the file's path to generate the fs structure
104
- // eslint-disable-next-line no-restricted-syntax
105
- for (const dir of breadcrumb) {
97
+ breadcrumb.forEach((dir) => {
106
98
  if (typeof currentDir[dir] === 'undefined') {
107
99
  currentDir[dir] = {}; // Create new folder.
108
100
  }
109
101
  currentDir = currentDir[dir]; // Go into the subdirectory.
110
- }
102
+ });
111
103
  currentDir[`${docIdPrefix}${doc.id}`] = null; // We've walked through the file path. Register the file in this directory.
112
104
  });
113
105
  return treeRoot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4426",
3
+ "version": "0.0.0-4430",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/core": "0.0.0-4426",
26
- "@docusaurus/logger": "0.0.0-4426",
27
- "@docusaurus/mdx-loader": "0.0.0-4426",
28
- "@docusaurus/utils": "0.0.0-4426",
29
- "@docusaurus/utils-validation": "0.0.0-4426",
25
+ "@docusaurus/core": "0.0.0-4430",
26
+ "@docusaurus/logger": "0.0.0-4430",
27
+ "@docusaurus/mdx-loader": "0.0.0-4430",
28
+ "@docusaurus/utils": "0.0.0-4430",
29
+ "@docusaurus/utils-validation": "0.0.0-4430",
30
30
  "combine-promises": "^1.1.0",
31
31
  "escape-string-regexp": "^4.0.0",
32
32
  "fs-extra": "^10.0.0",
@@ -42,8 +42,8 @@
42
42
  "webpack": "^5.61.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4426",
46
- "@docusaurus/types": "0.0.0-4426",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4430",
46
+ "@docusaurus/types": "0.0.0-4430",
47
47
  "@types/js-yaml": "^4.0.0",
48
48
  "@types/picomatch": "^2.2.1",
49
49
  "commander": "^5.1.0",
@@ -57,5 +57,5 @@
57
57
  "engines": {
58
58
  "node": ">=14"
59
59
  },
60
- "gitHead": "fe6eb624cb88769d26246ed4c58542a90d6325e4"
60
+ "gitHead": "548160af2a7413bdb58a37c37b73ff65be106db9"
61
61
  }
@@ -15,7 +15,11 @@ import type {
15
15
  SidebarItemCategoryLinkConfig,
16
16
  } from './types';
17
17
  import {sortBy, last} from 'lodash';
18
- import {addTrailingSlash, posixPath} from '@docusaurus/utils';
18
+ import {
19
+ addTrailingSlash,
20
+ posixPath,
21
+ findAsyncSequential,
22
+ } from '@docusaurus/utils';
19
23
  import logger from '@docusaurus/logger';
20
24
  import path from 'path';
21
25
  import fs from 'fs-extra';
@@ -76,17 +80,15 @@ async function readCategoryMetadataFile(
76
80
  throw e;
77
81
  }
78
82
  }
79
- // eslint-disable-next-line no-restricted-syntax
80
- for (const ext of ['.json', '.yml', '.yaml']) {
81
- // Simpler to use only posix paths for mocking file metadata in tests
82
- const filePath = posixPath(
83
- path.join(categoryDirPath, `${CategoryMetadataFilenameBase}${ext}`),
84
- );
85
- if (await fs.pathExists(filePath)) {
86
- return tryReadFile(filePath);
87
- }
88
- }
89
- return null;
83
+ const filePath = await findAsyncSequential(
84
+ ['.json', '.yml', '.yaml'].map((ext) =>
85
+ posixPath(
86
+ path.join(categoryDirPath, `${CategoryMetadataFilenameBase}${ext}`),
87
+ ),
88
+ ),
89
+ fs.pathExists,
90
+ );
91
+ return filePath ? tryReadFile(filePath) : null;
90
92
  }
91
93
 
92
94
  // Comment for this feature: https://github.com/facebook/docusaurus/issues/3464#issuecomment-818670449
@@ -154,13 +156,12 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
154
156
  docs.forEach((doc) => {
155
157
  const breadcrumb = getRelativeBreadcrumb(doc);
156
158
  let currentDir = treeRoot; // We walk down the file's path to generate the fs structure
157
- // eslint-disable-next-line no-restricted-syntax
158
- for (const dir of breadcrumb) {
159
+ breadcrumb.forEach((dir) => {
159
160
  if (typeof currentDir[dir] === 'undefined') {
160
161
  currentDir[dir] = {}; // Create new folder.
161
162
  }
162
163
  currentDir = currentDir[dir]!; // Go into the subdirectory.
163
- }
164
+ });
164
165
  currentDir[`${docIdPrefix}${doc.id}`] = null; // We've walked through the file path. Register the file in this directory.
165
166
  });
166
167
  return treeRoot;