Skip to content

Commit

Permalink
chore: rename docs -> feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 15, 2024
1 parent 6798176 commit cc3dcda
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions .github/scripts/create-rss.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getYearAndWeek(date) {
const { year, week } = getYearAndWeek(new Date(issueDate));
/** 根据年份和周数生成文件名称,如 2024-01.json */
const rssFilePath = `./docs/rss/${year}-${week}.json`;
const rssFilePath = `./feeds/rss/${year}-${week}.json`;

;(async () => {
// 读取 rssFilePath 文件内容,如果文件不存在创建它并则返回空数组
Expand All @@ -60,7 +60,7 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
const bannerImage = issueBody.match(/!\[.*?\]\((.*?)\)/);

try {
await fs.ensureDir('./docs/rss');
await fs.ensureDir('./feeds/rss');
if (fs.existsSync(rssFilePath)) {
rss = await fs.readJSON(rssFilePath);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
// 输出写入成功日志
info(`RSS 文件写入成功:${rssFilePath}`);

const oldRss = await fs.readJSON('./docs/old.json');
const oldRss = await fs.readJSON('./feeds/old.json');
// oldRss.items 和 rss.items 合并
// 新的 newItems 根据时间排序,通过id 去重
let rssItems = oldRss.concat(rss)
Expand All @@ -110,8 +110,8 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
index === self.findIndex((t) => t.id === item.id)
);
await fs.writeJSON('./docs/old.json', uniqueArray, { spaces: 2 });
info(`Old RSS 文件写入成功:./docs/old.json`);
await fs.writeJSON('./feeds/old.json', uniqueArray, { spaces: 2 });
info(`Old RSS 文件写入成功:./feeds/old.json`);
const feed = new Feed({
title: "Quick RSS Feed",
Expand Down Expand Up @@ -156,22 +156,22 @@ const rssFilePath = `./docs/rss/${year}-${week}.json`;
})
})
const markdownContent = fs.readFileSync('./docs/feed.md', 'utf-8');
const markdownContent = fs.readFileSync('./feeds/feed.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/feed.md', contentx);
fs.writeFileSync('./feeds/feed.md', contentx);
// 输出写入成功日志
info(`feed.md 文件写入成功:./docs/feed.md`);
info(`feed.md 文件写入成功:./feeds/feed.md`);
const jsonFeedPath = './docs/feed.json';
const jsonFeedPath = './feeds/feed.json';
await fs.writeFile(jsonFeedPath, feed.json1());
info(`JSON Feed 文件写入成功:${jsonFeedPath}`);

const atom1FeedPath = './docs/feed.xml';
const atom1FeedPath = './feeds/feed.xml';
await fs.writeFile(atom1FeedPath, feed.atom1());
info(`Atom1 Feed 文件写入成功:${atom1FeedPath}`);

const rss2FeedPath = './docs/rss.xml';
const rss2FeedPath = './feeds/rss.xml';
await fs.writeFile(rss2FeedPath, feed.rss2());
info(`RSS2 Feed 文件写入成功:${rss2FeedPath}`);

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- terms-of-service.zh.md
- privacy-policy.md
- privacy-policy.zh.md
- docs/feed.md
- feeds/feed.md
footer: |
<a href="./terms-of-service.html" target="_blank">Terms of Service</a>
<a href="./privacy-policy.html" target="_blank">Privacy Policy</a>
Expand All @@ -72,8 +72,8 @@ jobs:
- run: npm install idoc@1 -g
- run: idoc
- run: |
cp -rp docs/*.json dist/
cp -rp docs/*.xml dist/
cp -rp feeds/*.json dist/
cp -rp feeds/*.xml dist/

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
Expand Down
1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

1 change: 1 addition & 0 deletions feeds/README.md
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit cc3dcda

Please sign in to comment.