mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
* fix(route): hk01 get fulltext and refactor to V2 * Update lib/v2/hk01/channel.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/hk01/issue.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: teaser pubDate
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
const got = require('@/utils/got');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id;
|
|
|
|
const response = await got(`https://web-data.api.hk01.com/v2/page/zone/${id}`);
|
|
const data = response.data;
|
|
const list = data.sections[0].items;
|
|
|
|
ctx.state.data = {
|
|
title: `香港01 - ${data.zone.publishName}`,
|
|
description: data.meta.metaDesc,
|
|
link: data.zone.publishUrl,
|
|
item: list.map((item) => {
|
|
let author;
|
|
let description;
|
|
let pubDate;
|
|
switch (item.type) {
|
|
case 1:
|
|
author = item.data.authors && item.data.authors.map((e) => e.publishName).join(', ');
|
|
description = `<p>${item.data.description}</p><img style="width: 100%" src="${item.data.mainImage.cdnUrl}" />`;
|
|
pubDate = parseDate(item.data.lastModifyTime * 1000);
|
|
break;
|
|
case 2:
|
|
author = item.data.zonePublishName;
|
|
description = `${item.data.teaser.map((e) => '<p>' + e + '</p>').join('')}<img style="width: 100%" src="${item.data.mainImage.cdnUrl}" />`;
|
|
pubDate = parseDate(item.data.lastModifyTime * 1000);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return {
|
|
title: item.data.title,
|
|
author,
|
|
description,
|
|
pubDate,
|
|
link: item.data.canonicalUrl,
|
|
};
|
|
}),
|
|
};
|
|
};
|