Files
RSSHub/lib/v2/discourse/posts.js
T
2024-02-28 16:25:59 +08:00

26 lines
606 B
JavaScript

const { getConfig } = require('./utils');
import got from '@/utils/got';
const RSSParser = require('@/utils/rss-parser');
module.exports = async (ctx) => {
const { link, key } = getConfig(ctx);
const feed = await RSSParser.parseString(
(
await got(`${link}/posts.rss`, {
headers: {
'User-Api-Key': key,
},
})
).data
);
feed.items = feed.items.map((e) => ({
description: e.content,
author: e.creator,
...e,
}));
ctx.state.data = { item: feed.items, ...feed };
};