Files
RSSHub/lib/v2/panewslab/newsflash.js
Ethan Shen 00f641ca15 feat(route): add PANews (#9116)
* feat(route): add PANews

* fix typo
2022-02-19 16:57:52 +08:00

36 lines
1.0 KiB
JavaScript

const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const language = ctx.params.language ?? 'zh';
const rootUrl = 'https://panewslab.com';
const apiUrl = `${rootUrl}/api/sqtopic/pageBy`;
const currentUrl = `${rootUrl}/${language}/news/index.html`;
const response = await got({
method: 'post',
url: apiUrl,
form: {
language,
pageIndex: 1,
pageSize: 50,
topicState: 'PUBLISHED',
},
});
const items = response.data.data.list[0].data.map((item) => ({
title: item.title,
author: item.nick_name,
pubDate: parseDate(item.create_time),
link: `${rootUrl}/${language}/sqarticledetails/${item.id}.html`,
description: `<p>${item.content.replace(/来源链接$/, '').replace(/原文链接$/, '')}</p>`,
}));
ctx.state.data = {
title: 'PANews - 快讯',
link: currentUrl,
item: items,
};
};