mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
feat: add linux patchwork comments (#1327)
This commit is contained in:
32
lib/routes/patchwork.kernel.org/comments.js
Normal file
32
lib/routes/patchwork.kernel.org/comments.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cache = require('./cache');
|
||||
const he = require('he');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const name = await cache.getPatchnameFromID(ctx, id);
|
||||
|
||||
const host = `https://patchwork.kernel.org/patch/${id}/`;
|
||||
const url = `https://patchwork.kernel.org/api/patches/${id}/comments/`;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
params: {
|
||||
order: '-date',
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} - Comments`,
|
||||
link: host,
|
||||
item: data.map((item) => ({
|
||||
title: item.subject,
|
||||
description: he.escape(he.escape(item.content)).replace(/\n/g, '<br>'),
|
||||
pubDate: new Date(item.date).toUTCString(),
|
||||
link: item.web_url,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user