mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
feat(route): hackmd (#11560)
* Add HackMD RSS source * Adapt to v2 router & minor fixes Co-authored-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
@@ -273,6 +273,12 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News
|
||||
|
||||
<RouteEn author="cf020031308 nczitzk xie-dongping" example="/hackernews/threads/comments_list/dang" path="/hackernews/:section?/:type?/:user?" :paramsDesc="['Section, see above, `index` by default', 'Link, see above, `sources` by default', 'User, only valid for section `threads` and `submitted`']" />
|
||||
|
||||
## HackMD
|
||||
|
||||
### Profile
|
||||
|
||||
<RouteEn author="Yukaii kaiix" example="/hackmd/profile/hackmd" path="/hackmd/profile/:path" :paramsDesc="['userpath or teampath']" radar="1"/>
|
||||
|
||||
## Hex-Rays
|
||||
|
||||
### Hex-Rays News
|
||||
|
||||
@@ -389,6 +389,12 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="cf020031308 nczitzk xie-dongping" example="/hackernews/threads/comments_list/dang" path="/hackernews/:section?/:type?/:user?" :paramsDesc="['内容分区,见上表,默认为 `index`', '链接类型,见上表,默认为 `sources`', '设定用户,只在 `threads` 和 `submitted` 分区有效']" />
|
||||
|
||||
## HackMD
|
||||
|
||||
### Profile
|
||||
|
||||
<Route author="Yukaii kaiix" example="/hackmd/profile/hackmd" path="/hackmd/profile/:path" :paramsDesc="['個人名稱路徑,或團隊網址']" radar="1"/>
|
||||
|
||||
## HelloGitHub
|
||||
|
||||
### 热门
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/profile/:path': ['Yukaii', 'kaiix'],
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
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}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'hackmd.io': {
|
||||
_name: 'HackMD',
|
||||
'.': [
|
||||
{
|
||||
title: 'Profile',
|
||||
docs: 'http://docs.rsshub.app/programming.html#hackmd',
|
||||
source: ['/:profile'],
|
||||
target: (params) => `/hackmd/profile/${params.replace('@', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/profile/:path', require('./profile'));
|
||||
};
|
||||
Reference in New Issue
Block a user