@rspress/plugin-rss 2.0.0-beta.11 → 2.0.0-beta.13
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/dist/index.js +13 -13
- package/package.json +5 -5
package/dist/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
1
|
+
import external_node_path_default, { dirname } from "node:path";
|
2
|
+
import { resolve } from "node:url";
|
3
|
+
import { getIconUrlPath } from "@rspress/shared/node-utils";
|
4
|
+
import { Feed } from "feed";
|
5
|
+
import { promises } from "node:fs";
|
6
6
|
function notNullish(n) {
|
7
7
|
return null != n;
|
8
8
|
}
|
@@ -27,12 +27,12 @@ function sortByDate(l, r) {
|
|
27
27
|
return (r ? r.getTime() : 0) - (l ? l.getTime() : 0);
|
28
28
|
}
|
29
29
|
async function writeFile(path, content) {
|
30
|
-
const dir =
|
31
|
-
await
|
30
|
+
const dir = dirname(path);
|
31
|
+
await promises.mkdir(dir, {
|
32
32
|
mode: 493,
|
33
33
|
recursive: true
|
34
34
|
});
|
35
|
-
return
|
35
|
+
return promises.writeFile(path, content);
|
36
36
|
}
|
37
37
|
function generateFeedItem(page, siteUrl) {
|
38
38
|
const { frontmatter: fm } = page;
|
@@ -40,7 +40,7 @@ function generateFeedItem(page, siteUrl) {
|
|
40
40
|
id: selectNonNullishProperty(fm.slug, fm.id, page.id) || '',
|
41
41
|
title: selectNonNullishProperty(fm.title, page.title) || '',
|
42
42
|
author: toAuthors(fm.author),
|
43
|
-
link:
|
43
|
+
link: resolve(siteUrl, selectNonNullishProperty(fm.permalink, page.routePath) || ''),
|
44
44
|
description: selectNonNullishProperty(fm.description) || '',
|
45
45
|
content: selectNonNullishProperty(fm.summary, page._html) || '',
|
46
46
|
date: toDate(fm.date || fm.published_at),
|
@@ -128,7 +128,7 @@ function getOutputInfo({ id, output }, { siteUrl, output: globalOutput }) {
|
|
128
128
|
publicPath,
|
129
129
|
`${dir}/`,
|
130
130
|
filename
|
131
|
-
].reduce((u, part)=>u ?
|
131
|
+
].reduce((u, part)=>u ? resolve(u, part) : part);
|
132
132
|
const sorting = output?.sorting || globalOutput?.sorting || ((l, r)=>sortByDate(l.date, r.date));
|
133
133
|
return {
|
134
134
|
type,
|
@@ -153,7 +153,7 @@ class FeedsSet {
|
|
153
153
|
]).map((options)=>({
|
154
154
|
title: config.title || '',
|
155
155
|
description: config.description || '',
|
156
|
-
favicon: config.icon &&
|
156
|
+
favicon: config.icon && resolve(siteUrl, getIconUrlPath(config.icon)),
|
157
157
|
copyright: config.themeConfig?.footer?.message || '',
|
158
158
|
link: siteUrl,
|
159
159
|
docs: '',
|
@@ -219,13 +219,13 @@ function pluginRss(pluginRssOptions) {
|
|
219
219
|
const items = concatArray(...await Promise.all(Object.values(_rssWorkaround)));
|
220
220
|
const feeds = Object.create(null);
|
221
221
|
for (const { channel, ...item } of items){
|
222
|
-
feeds[channel] = feeds[channel] || new
|
222
|
+
feeds[channel] = feeds[channel] || new Feed(createFeed(feedsSet.get(channel), config));
|
223
223
|
feeds[channel].addItem(item);
|
224
224
|
}
|
225
225
|
for (const [channel, feed] of Object.entries(feeds)){
|
226
226
|
const { output } = feedsSet.get(channel);
|
227
227
|
feed.items.sort(output.sorting);
|
228
|
-
const path =
|
228
|
+
const path = external_node_path_default.resolve(config.outDir || 'doc_build', output.dir, output.filename);
|
229
229
|
await writeFile(path, output.getContent(feed));
|
230
230
|
}
|
231
231
|
_rssWorkaround = null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/plugin-rss",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.13",
|
4
4
|
"description": "A plugin for rss generation for rspress",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
@@ -25,19 +25,19 @@
|
|
25
25
|
],
|
26
26
|
"dependencies": {
|
27
27
|
"feed": "^4.2.2",
|
28
|
-
"@rspress/shared": "2.0.0-beta.
|
28
|
+
"@rspress/shared": "2.0.0-beta.13"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
|
-
"@rslib/core": "0.
|
31
|
+
"@rslib/core": "0.9.2",
|
32
32
|
"@types/node": "^22.8.1",
|
33
33
|
"@types/react": "^19.1.6",
|
34
34
|
"react": "^19.1.0",
|
35
35
|
"rsbuild-plugin-publint": "^0.3.2",
|
36
36
|
"typescript": "^5.8.2",
|
37
|
-
"@rspress/runtime": "2.0.0-beta.
|
37
|
+
"@rspress/runtime": "2.0.0-beta.13"
|
38
38
|
},
|
39
39
|
"peerDependencies": {
|
40
|
-
"rspress": "^2.0.0-beta.
|
40
|
+
"rspress": "^2.0.0-beta.13"
|
41
41
|
},
|
42
42
|
"engines": {
|
43
43
|
"node": ">=18.0.0"
|