Skip to content

Commit

Permalink
chore: update issue template scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 15, 2024
1 parent d80b980 commit ce62f88
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
21 changes: 19 additions & 2 deletions .github/scripts/create-rss.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
await fs.writeJSON(rssFilePath, rss, { spaces: 2 });
// 输出写入成功日志
info(`RSS 文件写入成功:${rssFilePath}`);

const oldRss = await fs.readJSON('./docs/rss.json');
// oldRss.items 和 rss.items 合并
// 新的 newItems 根据时间排序,通过id 去重
const rssItems = oldRss.items.concat(rss).sort((a, b) => new Date(b.date_published) - new Date(a.date_published))
.filter((item, index, self) => self.findIndex(t => t.id === item.id) === index)
.slice(0, 100);
const feed = new Feed({
title: "Quick RSS Feed",
Expand All @@ -121,8 +128,10 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
link: "https://wangchujiang.com/"
}
});

rss.forEach(post => {
let mdListContent = "";
rssItems.forEach(post => {
mdListContent += `- [${post.title}](${post.url}) [#${post.id}](https://github.com/jaywcjlove/quick-rss/issues/${post.id})\n`;
feed.addItem({
title: post.title,
id: post.id,
Expand All @@ -139,6 +148,14 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
],
})
})
const markdownContent = fs.readFileSync('./docs/README.md', 'utf-8');
// <!--RSS_LIST_START--><!--RSS_LIST_END-->
const contentx = markdownContent.replace(/<!--RSS_LIST_START-->[\s\S]*<!--RSS_LIST_END-->/g, `<!--RSS_LIST_START-->\n${mdListContent}\n<!--RSS_LIST_END-->`);
fs.writeFileSync('./docs/README.md', contentx);
// 输出写入成功日志
info(`README.md 文件写入成功:./docs/README.md`);
const jsonFeedPath = './docs/feed.json';
await fs.writeFile(jsonFeedPath, feed.json1());
info(`JSON Feed 文件写入成功:${jsonFeedPath}`);
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
target: __blank
sideEffectFiles:
- README.zh.md
- docs/README.md
- terms-of-service.md
- terms-of-service.zh.md
- privacy-policy.md
Expand Down
9 changes: 7 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Quick RSS Feed
===

Recording and sharing tech content, thank you for your contribution! Please provide the following information to submit, recommend, or self-recommend your articles, software, or resources, which will be added to Quick RSS subscriptions by default.
Thank you for recording and sharing tech content! You can subscribe to the valuable content shared by the community through the RSS link below. Additionally, you can submit, recommend, or self-nominate your articles, software, or resources via an issue, and they will be automatically added to the RSS feed.

```
https://wangchujiang.com/quick-rss/atom.xml
```
```

## 内容列表

<!--RSS_LIST_START-->
<!--RSS_LIST_END-->

0 comments on commit ce62f88

Please sign in to comment.