mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-16 21:02:57 +08:00
fix(route): preserve source dates in chiculture topics
This commit is contained in:
@@ -39,7 +39,7 @@ async function handler(ctx) {
|
||||
|
||||
const list = response.data.data.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: item.tags,
|
||||
category: item.tags.map((tag) => tag.title),
|
||||
link: `${rootUrl}${item.url}`,
|
||||
}));
|
||||
|
||||
@@ -52,29 +52,28 @@ async function handler(ctx) {
|
||||
});
|
||||
const content = load(detailResponse.data);
|
||||
|
||||
const pubDate = detailResponse.data.match(/上載日期:(.*)<\/p>/);
|
||||
const uploadDate = content('#article_main_content')
|
||||
.text()
|
||||
.match(/上載日期[::]\s*(\d{4}年\d{1,2}月(?:\d{1,2}日)?)/)?.[1];
|
||||
let pubDate: Date | undefined;
|
||||
|
||||
if (pubDate) {
|
||||
item.pubDate = parseDate(pubDate[1]);
|
||||
if (uploadDate) {
|
||||
pubDate = timezone(parseDate(uploadDate, ['YYYY年M月D日', 'YYYY年M月'], true), 8);
|
||||
} else if (item.title.includes('一周時事通識')) {
|
||||
for (const tag of item.pubDate) {
|
||||
if (!/^\d{4}年$/.test(tag.title)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const monthDayStr = item.title.split('- ', 2)[1] ?? item.title.split('-', 2)[1];
|
||||
item.pubDate = timezone(parseDate(monthDayStr, 'D/M'), 8);
|
||||
break;
|
||||
const year = item.category.find((tag) => /^\d{4}年$/.test(tag))?.slice(0, 4);
|
||||
const monthDay = item.title.match(/\d{1,2}\/\d{1,2}\s*-\s*(\d{1,2}\/\d{1,2})/)?.[1];
|
||||
if (year && monthDay) {
|
||||
pubDate = timezone(parseDate(`${year} ${monthDay}`, 'YYYY D/M', true), 8);
|
||||
}
|
||||
} else if (/^\d{4}年新聞回顧$/.test(item.title)) {
|
||||
item.pubDate = parseDate(`${item.title.split('年', 1)[0]}-12-31`);
|
||||
} else {
|
||||
item.pubDate = '';
|
||||
pubDate = timezone(parseDate(`${item.title.split('年', 1)[0]}-12-31`, 'YYYY-MM-DD', true), 8);
|
||||
}
|
||||
|
||||
item.description = content('#article_main_content').html();
|
||||
|
||||
return item;
|
||||
return {
|
||||
...item,
|
||||
pubDate: pubDate && !Number.isNaN(pubDate.getTime()) ? pubDate : undefined,
|
||||
description: content('#article_main_content').html(),
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user