Files
RSSHub/lib/v2/hackmd/profile.js
kaiix 7e3e034b56 feat(route): hackmd (#11560)
* Add HackMD RSS source

* Adapt to v2 router & minor fixes

Co-authored-by: Yukai Huang <yukaihuangtw@gmail.com>
2023-01-08 02:30:17 +08:00

25 lines
770 B
JavaScript

const got = require('@/utils/got');
module.exports = async (ctx) => {
const path = ctx.params.path;
const response = await got({
method: 'get',
url: `https://hackmd.io/api/@${path}/overview`,
});
const data = response.data;
const profile = data.user || data.team;
ctx.state.data = {
title: `${profile.name}'s Profile`,
link: `https://hackmd.io/@${path}`,
description: `${profile.name}'s profile on HackMD`,
item: data.notes.map((note) => ({
title: note.title,
description: `<pre>${note.content}</pre>`,
pubDate: new Date(note.publishedAt).toUTCString(),
link: `https://hackmd.io/@${path}/${note.permalink || note.shortId}`,
})),
};
};