feat(rss): 添加RSS订阅功能并优化日期处理
- 在DEPLOYMENT.md中添加RSS_FEED_URL环境变量配置说明 - 修改日期处理函数,统一使用GMT时区格式 - 实现RSS订阅功能,支持通过Feedly等阅读器订阅 - 优化GitHub API调用的Base64编解码处理 - 更新README展示RSS订阅链接和访问方式
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { replaceImageProxy, formatDateToChineseWithTime } from '../helpers.js';
|
||||
import { replaceImageProxy, formatDateToGMT0WithTime } from '../helpers.js';
|
||||
import { getDailyReportContent } from '../github.js';
|
||||
import { storeInKV } from '../kv.js';
|
||||
import { marked } from '../marked.esm.js';
|
||||
@@ -24,16 +24,17 @@ export async function handleWriteRssData(request, env) {
|
||||
link: '/daily/'+dateStr+'.html',
|
||||
content_html: null,
|
||||
// 可以添加其他相關欄位,例如作者、來源等
|
||||
published_date: formatDateToChineseWithTime(new Date()) // 記錄保存時間
|
||||
published_date: formatDateToGMT0WithTime(new Date()) // 記錄保存時間
|
||||
}
|
||||
report.content_html = marked.parse(replaceImageProxy(env.IMG_PROXY, content));
|
||||
storeInKV(env.DATA_KV, `${dateStr}-report`, report);
|
||||
|
||||
return new Response(JSON.stringify({ message: `Successfully fetched and stored daily report for ${dateStr}`}), {
|
||||
return new Response(JSON.stringify(report), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
status: 200
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error handling daily report:', error);
|
||||
console.error('Error handling daily report:', error.message);
|
||||
return new Response(`Error handling daily report: ${error.message}`, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user