Files
RSSHub/lib/v2/qbitai/category.js
T
Yu Fan 6c3eb6d0a8 feat(route): add 量子位 (#13874)
* feat(route): add 量子位

* Initial commit

* fix(route): replace xml2js with rss-parser

* Apply suggestions from code review

* docs: move to new-media

---------
2023-11-24 22:35:14 +08:00

28 lines
777 B
JavaScript

const parser = require('@/utils/rss-parser');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const { category } = ctx.params;
const link = encodeURI(`https://www.qbitai.com/category/${category}/feed`);
const feed = await parser.parseURL(link);
const items = feed.items.map((item) => ({
title: item.title,
pubDate: parseDate(item.pubDate),
link: item.link,
author: '量子位',
category: item.categories,
description: item['content:encoded'],
}));
ctx.state.data = {
// 源标题
title: `量子位-${category}`,
// 源链接
link: `https://www.qbitai.com/category/${category}`,
// 源文章
item: items,
};
};