@docusaurus/plugin-content-blog 3.9.2-canary-6495 → 3.9.2-canary-6526

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.
@@ -4,6 +4,7 @@
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
+ import type { TagsFile } from '@docusaurus/utils';
7
8
  import type { LoadContext } from '@docusaurus/types';
8
9
  import type { AuthorsMap, PluginOptions, BlogPost, BlogTags, BlogPaginated } from '@docusaurus/plugin-content-blog';
9
10
  import type { BlogContentPaths } from './types';
@@ -34,7 +35,7 @@ type ParsedBlogFileName = {
34
35
  slug: string;
35
36
  };
36
37
  export declare function parseBlogFileName(blogSourceRelative: string): ParsedBlogFileName;
37
- export declare function generateBlogPosts(contentPaths: BlogContentPaths, context: LoadContext, options: PluginOptions, authorsMap?: AuthorsMap): Promise<BlogPost[]>;
38
+ export declare function generateBlogPosts(contentPaths: BlogContentPaths, context: LoadContext, options: PluginOptions, tagsFile: TagsFile | null, authorsMap?: AuthorsMap): Promise<BlogPost[]>;
38
39
  export declare function applyProcessBlogPosts({ blogPosts, processBlogPosts, }: {
39
40
  blogPosts: BlogPost[];
40
41
  processBlogPosts: PluginOptions['processBlogPosts'];
package/lib/blogUtils.js CHANGED
@@ -20,7 +20,6 @@ const path_1 = tslib_1.__importDefault(require("path"));
20
20
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
21
21
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
22
22
  const utils_1 = require("@docusaurus/utils");
23
- const utils_validation_1 = require("@docusaurus/utils-validation");
24
23
  const frontMatter_1 = require("./frontMatter");
25
24
  const authors_1 = require("./authors");
26
25
  const authorsProblems_1 = require("./authorsProblems");
@@ -247,7 +246,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
247
246
  content,
248
247
  };
249
248
  }
250
- async function generateBlogPosts(contentPaths, context, options, authorsMap) {
249
+ async function generateBlogPosts(contentPaths, context, options, tagsFile, authorsMap) {
251
250
  const { include, exclude } = options;
252
251
  if (!(await fs_extra_1.default.pathExists(contentPaths.contentPath))) {
253
252
  return [];
@@ -256,9 +255,6 @@ async function generateBlogPosts(contentPaths, context, options, authorsMap) {
256
255
  cwd: contentPaths.contentPath,
257
256
  ignore: exclude,
258
257
  });
259
- // TODO this should be done outside of this function
260
- // directly in plugin loadContent()
261
- const tagsFile = await (0, utils_validation_1.getTagsFile)({ contentPaths, tags: options.tags });
262
258
  async function doProcessBlogSourceFile(blogSourceFile) {
263
259
  try {
264
260
  return await processBlogSourceFile(blogSourceFile, contentPaths, context, options, tagsFile, authorsMap);
package/lib/feed.js CHANGED
@@ -116,7 +116,7 @@ async function resolveXsltFilePaths({ xsltFilePath, contentPaths, }) {
116
116
  }
117
117
  const parsedPath = path_1.default.parse(xsltAbsolutePath);
118
118
  const cssAbsolutePath = path_1.default.resolve(parsedPath.dir, `${parsedPath.name}.css`);
119
- if (!(await fs_extra_1.default.pathExists(xsltAbsolutePath))) {
119
+ if (!(await fs_extra_1.default.pathExists(cssAbsolutePath))) {
120
120
  throw new Error(logger_1.default.interpolate `Blog feed XSLT file was found at path=${path_1.default.relative(process.cwd(), xsltAbsolutePath)}
121
121
  But its expected co-located CSS file could not be found at path=${path_1.default.relative(process.cwd(), cssAbsolutePath)}
122
122
  If you want to provide a custom XSLT file, you must provide a CSS file with the exact same name.`);
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ exports.default = pluginContentBlog;
11
11
  const tslib_1 = require("tslib");
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
14
15
  const utils_1 = require("@docusaurus/utils");
15
16
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
17
  const mdx_loader_1 = require("@docusaurus/mdx-loader");
@@ -141,18 +142,26 @@ async function pluginContentBlog(context, options) {
141
142
  const { postsPerPage: postsPerPageOption, routeBasePath, tagsBasePath, blogDescription, blogTitle, blogSidebarTitle, pageBasePath, authorsBasePath, authorsMapPath, } = options;
142
143
  const baseBlogUrl = (0, utils_1.normalizeUrl)([baseUrl, routeBasePath]);
143
144
  const blogTagsListPath = (0, utils_1.normalizeUrl)([baseBlogUrl, tagsBasePath]);
144
- const authorsMap = await (0, authorsMap_1.getAuthorsMap)({
145
- contentPaths,
146
- authorsMapPath,
147
- authorsBaseRoutePath: (0, utils_1.normalizeUrl)([
145
+ async function getAuthorsMapChecked() {
146
+ const result = await (0, authorsMap_1.getAuthorsMap)({
147
+ contentPaths,
148
+ authorsMapPath,
149
+ authorsBaseRoutePath: (0, utils_1.normalizeUrl)([
150
+ baseUrl,
151
+ routeBasePath,
152
+ authorsBasePath,
153
+ ]),
148
154
  baseUrl,
149
- routeBasePath,
150
- authorsBasePath,
151
- ]),
152
- baseUrl,
155
+ });
156
+ (0, authorsMap_1.checkAuthorsMapPermalinkCollisions)(result);
157
+ return result;
158
+ }
159
+ // Read all the input files in parallel
160
+ const { authorsMap, tagsFile } = await (0, combine_promises_1.default)({
161
+ authorsMap: getAuthorsMapChecked(),
162
+ tagsFile: (0, utils_validation_1.getTagsFile)({ contentPaths, tags: options.tags }),
153
163
  });
154
- (0, authorsMap_1.checkAuthorsMapPermalinkCollisions)(authorsMap);
155
- let blogPosts = await (0, blogUtils_1.generateBlogPosts)(contentPaths, context, options, authorsMap);
164
+ let blogPosts = await (0, blogUtils_1.generateBlogPosts)(contentPaths, context, options, tagsFile, authorsMap);
156
165
  blogPosts = await (0, blogUtils_1.applyProcessBlogPosts)({
157
166
  blogPosts,
158
167
  processBlogPosts: options.processBlogPosts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "3.9.2-canary-6495",
3
+ "version": "3.9.2-canary-6526",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -31,15 +31,16 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@docusaurus/core": "3.9.2-canary-6495",
35
- "@docusaurus/logger": "3.9.2-canary-6495",
36
- "@docusaurus/mdx-loader": "3.9.2-canary-6495",
37
- "@docusaurus/theme-common": "3.9.2-canary-6495",
38
- "@docusaurus/types": "3.9.2-canary-6495",
39
- "@docusaurus/utils": "3.9.2-canary-6495",
40
- "@docusaurus/utils-common": "3.9.2-canary-6495",
41
- "@docusaurus/utils-validation": "3.9.2-canary-6495",
34
+ "@docusaurus/core": "3.9.2-canary-6526",
35
+ "@docusaurus/logger": "3.9.2-canary-6526",
36
+ "@docusaurus/mdx-loader": "3.9.2-canary-6526",
37
+ "@docusaurus/theme-common": "3.9.2-canary-6526",
38
+ "@docusaurus/types": "3.9.2-canary-6526",
39
+ "@docusaurus/utils": "3.9.2-canary-6526",
40
+ "@docusaurus/utils-common": "3.9.2-canary-6526",
41
+ "@docusaurus/utils-validation": "3.9.2-canary-6526",
42
42
  "cheerio": "1.0.0-rc.12",
43
+ "combine-promises": "^1.1.0",
43
44
  "feed": "^4.2.2",
44
45
  "fs-extra": "^11.1.1",
45
46
  "lodash": "^4.17.21",
@@ -62,5 +63,5 @@
62
63
  "@total-typescript/shoehorn": "^0.1.2",
63
64
  "tree-node-cli": "^1.6.0"
64
65
  },
65
- "gitHead": "fb9b28015f40d530ceb623dc486a5b8f48902ca0"
66
+ "gitHead": "a37ae138931cb80b31664f86a34f97671c00e409"
66
67
  }
package/src/blogUtils.ts CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  normalizeTags,
27
27
  aliasedSitePathToRelativePath,
28
28
  } from '@docusaurus/utils';
29
- import {getTagsFile} from '@docusaurus/utils-validation';
29
+
30
30
  import {validateBlogPostFrontMatter} from './frontMatter';
31
31
  import {getBlogPostAuthors} from './authors';
32
32
  import {reportAuthorsProblems} from './authorsProblems';
@@ -388,6 +388,7 @@ export async function generateBlogPosts(
388
388
  contentPaths: BlogContentPaths,
389
389
  context: LoadContext,
390
390
  options: PluginOptions,
391
+ tagsFile: TagsFile | null,
391
392
  authorsMap?: AuthorsMap,
392
393
  ): Promise<BlogPost[]> {
393
394
  const {include, exclude} = options;
@@ -401,10 +402,6 @@ export async function generateBlogPosts(
401
402
  ignore: exclude,
402
403
  });
403
404
 
404
- // TODO this should be done outside of this function
405
- // directly in plugin loadContent()
406
- const tagsFile = await getTagsFile({contentPaths, tags: options.tags});
407
-
408
405
  async function doProcessBlogSourceFile(blogSourceFile: string) {
409
406
  try {
410
407
  return await processBlogSourceFile(
package/src/feed.ts CHANGED
@@ -213,7 +213,7 @@ async function resolveXsltFilePaths({
213
213
  parsedPath.dir,
214
214
  `${parsedPath.name}.css`,
215
215
  );
216
- if (!(await fs.pathExists(xsltAbsolutePath))) {
216
+ if (!(await fs.pathExists(cssAbsolutePath))) {
217
217
  throw new Error(
218
218
  logger.interpolate`Blog feed XSLT file was found at path=${path.relative(
219
219
  process.cwd(),
package/src/index.ts CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
  import path from 'path';
9
9
  import logger from '@docusaurus/logger';
10
+ import combinePromises from 'combine-promises';
11
+
10
12
  import {
11
13
  normalizeUrl,
12
14
  docuHash,
@@ -20,7 +22,10 @@ import {
20
22
  resolveMarkdownLinkPathname,
21
23
  getLocaleConfig,
22
24
  } from '@docusaurus/utils';
23
- import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
25
+ import {
26
+ getTagsFilePathsToWatch,
27
+ getTagsFile,
28
+ } from '@docusaurus/utils-validation';
24
29
  import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
25
30
  import {
26
31
  getBlogTags,
@@ -227,22 +232,32 @@ export default async function pluginContentBlog(
227
232
  const baseBlogUrl = normalizeUrl([baseUrl, routeBasePath]);
228
233
  const blogTagsListPath = normalizeUrl([baseBlogUrl, tagsBasePath]);
229
234
 
230
- const authorsMap = await getAuthorsMap({
231
- contentPaths,
232
- authorsMapPath,
233
- authorsBaseRoutePath: normalizeUrl([
235
+ async function getAuthorsMapChecked() {
236
+ const result = await getAuthorsMap({
237
+ contentPaths,
238
+ authorsMapPath,
239
+ authorsBaseRoutePath: normalizeUrl([
240
+ baseUrl,
241
+ routeBasePath,
242
+ authorsBasePath,
243
+ ]),
234
244
  baseUrl,
235
- routeBasePath,
236
- authorsBasePath,
237
- ]),
238
- baseUrl,
245
+ });
246
+ checkAuthorsMapPermalinkCollisions(result);
247
+ return result;
248
+ }
249
+
250
+ // Read all the input files in parallel
251
+ const {authorsMap, tagsFile} = await combinePromises({
252
+ authorsMap: getAuthorsMapChecked(),
253
+ tagsFile: getTagsFile({contentPaths, tags: options.tags}),
239
254
  });
240
- checkAuthorsMapPermalinkCollisions(authorsMap);
241
255
 
242
256
  let blogPosts = await generateBlogPosts(
243
257
  contentPaths,
244
258
  context,
245
259
  options,
260
+ tagsFile,
246
261
  authorsMap,
247
262
  );
248
263
  blogPosts = await applyProcessBlogPosts({