Files
RSSHub/lib/v2/hk01/zone.js
Fatpandac 2f9b999055 fix(route): hk01 get fulltext and refactor to V2 (#9937)
* 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
2022-06-13 22:00:48 +08:00

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,
};
}),
};
};