@docusaurus/plugin-content-blog 0.0.0-4878 → 0.0.0-4888

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.
Files changed (3) hide show
  1. package/lib/feed.js +3 -3
  2. package/package.json +9 -9
  3. package/src/feed.ts +40 -42
package/lib/feed.js CHANGED
@@ -35,7 +35,7 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, locale
35
35
  function toFeedAuthor(author) {
36
36
  return { name: author.name, link: author.url, email: author.email };
37
37
  }
38
- await (0, utils_1.mapAsyncSequential)(blogPosts, async (post) => {
38
+ await Promise.all(blogPosts.map(async (post) => {
39
39
  const { id, metadata: { title: metadataTitle, permalink, date, description, authors, tags, }, } = post;
40
40
  const content = await (0, utils_1.readOutputHTMLFile)(permalink.replace(siteConfig.baseUrl, ''), outDir, siteConfig.trailingSlash);
41
41
  const $ = (0, cheerio_1.load)(content);
@@ -55,8 +55,8 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, locale
55
55
  if (feedItemAuthors.length > 0) {
56
56
  feedItem.author = feedItemAuthors;
57
57
  }
58
- feed.addItem(feedItem);
59
- });
58
+ return feedItem;
59
+ })).then((items) => items.forEach(feed.addItem));
60
60
  return feed;
61
61
  }
62
62
  async function createBlogFeedFile({ feed, feedType, generatePath, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-4878",
3
+ "version": "0.0.0-4888",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -18,12 +18,12 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4878",
22
- "@docusaurus/logger": "0.0.0-4878",
23
- "@docusaurus/mdx-loader": "0.0.0-4878",
24
- "@docusaurus/utils": "0.0.0-4878",
25
- "@docusaurus/utils-common": "0.0.0-4878",
26
- "@docusaurus/utils-validation": "0.0.0-4878",
21
+ "@docusaurus/core": "0.0.0-4888",
22
+ "@docusaurus/logger": "0.0.0-4888",
23
+ "@docusaurus/mdx-loader": "0.0.0-4888",
24
+ "@docusaurus/utils": "0.0.0-4888",
25
+ "@docusaurus/utils-common": "0.0.0-4888",
26
+ "@docusaurus/utils-validation": "0.0.0-4888",
27
27
  "cheerio": "^1.0.0-rc.10",
28
28
  "feed": "^4.2.2",
29
29
  "fs-extra": "^10.1.0",
@@ -35,7 +35,7 @@
35
35
  "webpack": "^5.72.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@docusaurus/types": "0.0.0-4878",
38
+ "@docusaurus/types": "0.0.0-4888",
39
39
  "escape-string-regexp": "^4.0.0"
40
40
  },
41
41
  "peerDependencies": {
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=14"
47
47
  },
48
- "gitHead": "186f6b50623681da063421e72dd69726a8d78f9e"
48
+ "gitHead": "a02d37417f43c2ab8d73dd1b8bdec1450f7cc00e"
49
49
  }
package/src/feed.ts CHANGED
@@ -7,11 +7,7 @@
7
7
 
8
8
  import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed';
9
9
  import type {BlogPost} from './types';
10
- import {
11
- normalizeUrl,
12
- mapAsyncSequential,
13
- readOutputHTMLFile,
14
- } from '@docusaurus/utils';
10
+ import {normalizeUrl, readOutputHTMLFile} from '@docusaurus/utils';
15
11
  import {load as cheerioLoad} from 'cheerio';
16
12
  import type {DocusaurusConfig} from '@docusaurus/types';
17
13
  import path from 'path';
@@ -61,46 +57,48 @@ async function generateBlogFeed({
61
57
  return {name: author.name, link: author.url, email: author.email};
62
58
  }
63
59
 
64
- await mapAsyncSequential(blogPosts, async (post) => {
65
- const {
66
- id,
67
- metadata: {
60
+ await Promise.all(
61
+ blogPosts.map(async (post) => {
62
+ const {
63
+ id,
64
+ metadata: {
65
+ title: metadataTitle,
66
+ permalink,
67
+ date,
68
+ description,
69
+ authors,
70
+ tags,
71
+ },
72
+ } = post;
73
+
74
+ const content = await readOutputHTMLFile(
75
+ permalink.replace(siteConfig.baseUrl, ''),
76
+ outDir,
77
+ siteConfig.trailingSlash,
78
+ );
79
+ const $ = cheerioLoad(content);
80
+
81
+ const feedItem: FeedItem = {
68
82
  title: metadataTitle,
69
- permalink,
83
+ id,
84
+ link: normalizeUrl([siteUrl, permalink]),
70
85
  date,
71
86
  description,
72
- authors,
73
- tags,
74
- },
75
- } = post;
76
-
77
- const content = await readOutputHTMLFile(
78
- permalink.replace(siteConfig.baseUrl, ''),
79
- outDir,
80
- siteConfig.trailingSlash,
81
- );
82
- const $ = cheerioLoad(content);
83
-
84
- const feedItem: FeedItem = {
85
- title: metadataTitle,
86
- id,
87
- link: normalizeUrl([siteUrl, permalink]),
88
- date,
89
- description,
90
- // Atom feed demands the "term", while other feeds use "name"
91
- category: tags.map((tag) => ({name: tag.label, term: tag.label})),
92
- content: $(`#${blogPostContainerID}`).html()!,
93
- };
94
-
95
- // json1() method takes the first item of authors array
96
- // it causes an error when authors array is empty
97
- const feedItemAuthors = authors.map(toFeedAuthor);
98
- if (feedItemAuthors.length > 0) {
99
- feedItem.author = feedItemAuthors;
100
- }
101
-
102
- feed.addItem(feedItem);
103
- });
87
+ // Atom feed demands the "term", while other feeds use "name"
88
+ category: tags.map((tag) => ({name: tag.label, term: tag.label})),
89
+ content: $(`#${blogPostContainerID}`).html()!,
90
+ };
91
+
92
+ // json1() method takes the first item of authors array
93
+ // it causes an error when authors array is empty
94
+ const feedItemAuthors = authors.map(toFeedAuthor);
95
+ if (feedItemAuthors.length > 0) {
96
+ feedItem.author = feedItemAuthors;
97
+ }
98
+
99
+ return feedItem;
100
+ }),
101
+ ).then((items) => items.forEach(feed.addItem));
104
102
 
105
103
  return feed;
106
104
  }