mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
* Add HackMD RSS source * Adapt to v2 router & minor fixes Co-authored-by: Yukai Huang <yukaihuangtw@gmail.com>
25 lines
770 B
JavaScript
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}`,
|
|
})),
|
|
};
|
|
};
|