@docusaurus/plugin-content-blog 0.0.0-4875 → 0.0.0-4879

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/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/lib/index.js CHANGED
@@ -120,7 +120,7 @@ async function pluginContentBlog(context, options) {
120
120
  routeBasePath,
121
121
  archiveBasePath,
122
122
  ]);
123
- // creates a blog archive route
123
+ // Create a blog archive route
124
124
  const archiveProp = await createData(`${(0, utils_1.docuHash)(archiveUrl)}.json`, JSON.stringify({ blogPosts }, null, 2));
125
125
  addRoute({
126
126
  path: archiveUrl,
package/lib/options.js CHANGED
@@ -85,7 +85,7 @@ const PluginOptionSchema = utils_validation_1.Joi.object({
85
85
  .default(exports.DEFAULT_OPTIONS.feedOptions.type),
86
86
  title: utils_validation_1.Joi.string().allow(''),
87
87
  description: utils_validation_1.Joi.string().allow(''),
88
- // only add default value when user actually wants a feed (type is not null)
88
+ // Only add default value when user actually wants a feed (type is not null)
89
89
  copyright: utils_validation_1.Joi.when('type', {
90
90
  is: utils_validation_1.Joi.any().valid(null),
91
91
  then: utils_validation_1.Joi.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-4875",
3
+ "version": "0.0.0-4879",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4875",
22
- "@docusaurus/logger": "0.0.0-4875",
23
- "@docusaurus/mdx-loader": "0.0.0-4875",
24
- "@docusaurus/utils": "0.0.0-4875",
25
- "@docusaurus/utils-common": "0.0.0-4875",
26
- "@docusaurus/utils-validation": "0.0.0-4875",
21
+ "@docusaurus/core": "0.0.0-4879",
22
+ "@docusaurus/logger": "0.0.0-4879",
23
+ "@docusaurus/mdx-loader": "0.0.0-4879",
24
+ "@docusaurus/utils": "0.0.0-4879",
25
+ "@docusaurus/utils-common": "0.0.0-4879",
26
+ "@docusaurus/utils-validation": "0.0.0-4879",
27
27
  "cheerio": "^1.0.0-rc.10",
28
28
  "feed": "^4.2.2",
29
- "fs-extra": "^10.0.1",
29
+ "fs-extra": "^10.1.0",
30
30
  "lodash": "^4.17.21",
31
31
  "reading-time": "^1.5.0",
32
32
  "remark-admonitions": "^1.2.1",
@@ -35,7 +35,7 @@
35
35
  "webpack": "^5.72.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@docusaurus/types": "0.0.0-4875",
38
+ "@docusaurus/types": "0.0.0-4879",
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": "ee48d072632c7eb6d03da4acf5800f8d42eee680"
48
+ "gitHead": "0ebf7473396171d10b7c91bc3f33cdf16863ee5c"
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
  }
package/src/index.ts CHANGED
@@ -218,7 +218,7 @@ export default async function pluginContentBlog(
218
218
  routeBasePath,
219
219
  archiveBasePath,
220
220
  ]);
221
- // creates a blog archive route
221
+ // Create a blog archive route
222
222
  const archiveProp = await createData(
223
223
  `${docuHash(archiveUrl)}.json`,
224
224
  JSON.stringify({blogPosts}, null, 2),
package/src/options.ts CHANGED
@@ -111,7 +111,7 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
111
111
  .default(DEFAULT_OPTIONS.feedOptions.type),
112
112
  title: Joi.string().allow(''),
113
113
  description: Joi.string().allow(''),
114
- // only add default value when user actually wants a feed (type is not null)
114
+ // Only add default value when user actually wants a feed (type is not null)
115
115
  copyright: Joi.when('type', {
116
116
  is: Joi.any().valid(null),
117
117
  then: Joi.string().optional(),