File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -104,9 +104,13 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
104
104
// 新的 newItems 根据时间排序,通过id 去重
105
105
let rssItems = oldRss.concat(rss)
106
106
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 );
108
107
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 });
110
114
info(`Old RSS 文件写入成功:./docs/old.json`);
111
115
112
116
const feed = new Feed({
@@ -133,7 +137,7 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
133
137
});
134
138
135
139
let mdListContent = "";
136
- rssItems .forEach(post => {
140
+ uniqueArray .forEach(post => {
137
141
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`;
138
142
feed.addItem({
139
143
title: post.title,
You can’t perform that action at this time.
0 commit comments