Skip to content

Commit 4531020

Browse files
committed
chore: update issue template scripts
1 parent 68fea98 commit 4531020

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/scripts/create-rss.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
104104
// 新的 newItems 根据时间排序,通过id 去重
105105
let rssItems = oldRss.concat(rss)
106106
rssItems.sort((a, b) => new Date(b.date_published) - new Date(a.date_published))
107-
rssItems = rssItems.filter((item, index, self) => self.findIndex(t => t.id === item.id) === index).slice(0, 100);
108107

109-
await fs.writeFile('./docs/old.json', rssItems, { spaces: 2 });
108+
// 通过 rssItems 中的 id 去重复
109+
const uniqueArray = rssItems.filter((item, index, self) =>
110+
index === self.findIndex((t) => t.id === item.id)
111+
);
112+
113+
await fs.writeJSON('./docs/old.json', uniqueArray, { spaces: 2 });
110114
info(`Old RSS 文件写入成功:./docs/old.json`);
111115
112116
const feed = new Feed({
@@ -133,7 +137,7 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
133137
});
134138
135139
let mdListContent = "";
136-
rssItems.forEach(post => {
140+
uniqueArray.forEach(post => {
137141
mdListContent += `- [${post.title}](${post.url}) [#${post.id}](https://github.com/jaywcjlove/quick-rss/issues/${post.id}) [@${post.author.name}](https://github.com/${post.author.name})\n`;
138142
feed.addItem({
139143
title: post.title,

0 commit comments

Comments
 (0)