mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
* feat(route): add 量子位 * Initial commit * fix(route): replace xml2js with rss-parser * Apply suggestions from code review * docs: move to new-media ---------
28 lines
777 B
JavaScript
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,
|
|
};
|
|
};
|