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:
kaiix
2023-01-08 02:30:17 +08:00
committed by GitHub
co-authored by Yukai Huang
parent e749584ece
commit 7e3e034b56
6 changed files with 55 additions and 0 deletions
+6
View File
@@ -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
+6
View File
@@ -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
### 热门
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/profile/:path': ['Yukaii', 'kaiix'],
};
+24
View File
@@ -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}`,
})),
};
};
+13
View File
@@ -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('@', '')}`,
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/profile/:path', require('./profile'));
};