@docusaurus/plugin-content-blog 4.0.0-canary-6875 → 4.0.0-canary-6879

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 +10 -4
  2. package/package.json +13 -13
  3. package/src/feed.ts +12 -5
package/lib/feed.js CHANGED
@@ -48,14 +48,11 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, locale
48
48
  outDir,
49
49
  defaultCreateFeedItems,
50
50
  });
51
- feedItems.forEach(feed.addItem);
51
+ feedItems.forEach((item) => feed.addItem(item));
52
52
  return feed;
53
53
  }
54
54
  async function defaultCreateFeedItems({ blogPosts, siteConfig, outDir, }) {
55
55
  const { url: siteUrl, baseUrl, trailingSlash } = siteConfig;
56
- function toFeedAuthor(author) {
57
- return { name: author.name, link: author.url, email: author.email };
58
- }
59
56
  return Promise.all(blogPosts.map(async (post) => {
60
57
  const { metadata: { title: metadataTitle, permalink, date, description, authors, tags, }, } = post;
61
58
  const content = await (0, utils_1.readOutputHTMLFile)(permalink.replace(baseUrl, ''), outDir, trailingSlash);
@@ -97,6 +94,15 @@ async function defaultCreateFeedItems({ blogPosts, siteConfig, outDir, }) {
97
94
  category: tags.map((tag) => ({ name: tag.label, term: tag.label })),
98
95
  content: $(`#${utils_common_1.blogPostContainerID}`).html(),
99
96
  };
97
+ // Author urls can be relative, but the feed lib throws on these
98
+ // Absolute urls are kept as is to preserve the existing feed output
99
+ const toFeedAuthor = (author) => ({
100
+ name: author.name,
101
+ link: author.url && !URL.canParse(author.url)
102
+ ? toAbsoluteUrl(author.url)
103
+ : author.url,
104
+ email: author.email,
105
+ });
100
106
  // json1() method takes the first item of authors array
101
107
  // it causes an error when authors array is empty
102
108
  const feedItemAuthors = authors.map(toFeedAuthor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "4.0.0-canary-6875",
3
+ "version": "4.0.0-canary-6879",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -31,19 +31,19 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@docusaurus/core": "4.0.0-canary-6875",
35
- "@docusaurus/glob": "4.0.0-canary-6875",
36
- "@docusaurus/logger": "4.0.0-canary-6875",
37
- "@docusaurus/mdx-loader": "4.0.0-canary-6875",
38
- "@docusaurus/module-type-aliases": "4.0.0-canary-6875",
39
- "@docusaurus/theme-common": "4.0.0-canary-6875",
40
- "@docusaurus/types": "4.0.0-canary-6875",
41
- "@docusaurus/utils": "4.0.0-canary-6875",
42
- "@docusaurus/utils-common": "4.0.0-canary-6875",
43
- "@docusaurus/utils-validation": "4.0.0-canary-6875",
34
+ "@docusaurus/core": "4.0.0-canary-6879",
35
+ "@docusaurus/glob": "4.0.0-canary-6879",
36
+ "@docusaurus/logger": "4.0.0-canary-6879",
37
+ "@docusaurus/mdx-loader": "4.0.0-canary-6879",
38
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6879",
39
+ "@docusaurus/theme-common": "4.0.0-canary-6879",
40
+ "@docusaurus/types": "4.0.0-canary-6879",
41
+ "@docusaurus/utils": "4.0.0-canary-6879",
42
+ "@docusaurus/utils-common": "4.0.0-canary-6879",
43
+ "@docusaurus/utils-validation": "4.0.0-canary-6879",
44
44
  "cheerio": "^1.2.0",
45
45
  "combine-promises": "^1.2.0",
46
- "feed": "^5.2.1",
46
+ "feed": "^6.0.0",
47
47
  "fs-extra": "^11.4.0",
48
48
  "lodash": "^4.18.1",
49
49
  "schema-dts": "^1.1.5",
@@ -69,5 +69,5 @@
69
69
  "tree-node-cli": "^3.0.0",
70
70
  "unified": "^11.0.5"
71
71
  },
72
- "gitHead": "cbcdd6d829bd284fd2fd5e674c69b92f9d4604ce"
72
+ "gitHead": "d86dd389fe2697b91e54d351ecdc28498dead0f7"
73
73
  }
package/src/feed.ts CHANGED
@@ -87,7 +87,7 @@ async function generateBlogFeed({
87
87
  defaultCreateFeedItems,
88
88
  });
89
89
 
90
- feedItems.forEach(feed.addItem);
90
+ feedItems.forEach((item) => feed.addItem(item));
91
91
 
92
92
  return feed;
93
93
  }
@@ -103,10 +103,6 @@ async function defaultCreateFeedItems({
103
103
  }): Promise<BlogFeedItem[]> {
104
104
  const {url: siteUrl, baseUrl, trailingSlash} = siteConfig;
105
105
 
106
- function toFeedAuthor(author: Author): FeedAuthor {
107
- return {name: author.name, link: author.url, email: author.email};
108
- }
109
-
110
106
  return Promise.all(
111
107
  blogPosts.map(async (post) => {
112
108
  const {
@@ -175,6 +171,17 @@ async function defaultCreateFeedItems({
175
171
  content: $(`#${blogPostContainerID}`).html()!,
176
172
  };
177
173
 
174
+ // Author urls can be relative, but the feed lib throws on these
175
+ // Absolute urls are kept as is to preserve the existing feed output
176
+ const toFeedAuthor = (author: Author): FeedAuthor => ({
177
+ name: author.name,
178
+ link:
179
+ author.url && !URL.canParse(author.url)
180
+ ? toAbsoluteUrl(author.url)
181
+ : author.url,
182
+ email: author.email,
183
+ });
184
+
178
185
  // json1() method takes the first item of authors array
179
186
  // it causes an error when authors array is empty
180
187
  const feedItemAuthors = authors.map(toFeedAuthor);