@docusaurus/plugin-content-blog 0.0.0-4878 → 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 +3 -3
- package/package.json +9 -9
- 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 (
|
|
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
|
-
|
|
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-
|
|
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,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/logger": "0.0.0-
|
|
23
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
24
|
-
"@docusaurus/utils": "0.0.0-
|
|
25
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
26
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
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
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-
|
|
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": "
|
|
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
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
83
|
+
id,
|
|
84
|
+
link: normalizeUrl([siteUrl, permalink]),
|
|
70
85
|
date,
|
|
71
86
|
description,
|
|
72
|
-
|
|
73
|
-
tags,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
}
|