diff --git a/docs/bbs.md b/docs/bbs.md index 46cae0b359..5a6f8d1a5c 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -218,6 +218,12 @@ pageClass: routes +## HACKER TALK 黑客说 + +### 最新帖子 + + + ## LearnKu ### 社区 diff --git a/lib/v2/hackertalk/index.js b/lib/v2/hackertalk/index.js new file mode 100644 index 0000000000..56c7906bd9 --- /dev/null +++ b/lib/v2/hackertalk/index.js @@ -0,0 +1,23 @@ +const got = require('@/utils/got'); +const md = require('markdown-it')(); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const limit = ctx.query.limit ?? 25; + + const response = await got(`https://api.hackertalk.net/v1/posts?limit=${limit}&orderBy=time`); + + const data = response.data.data; + + ctx.state.data = { + title: '黑客说的最新帖子', + link: 'https://hackertalk.net/?tab=new', + description: '黑客说 - 技术驱动优质交流', + item: data.map((item) => ({ + title: item.title, + description: md.render(item.content), + pubDate: parseDate(item.createdAt), + link: `https://hackertalk.net/posts/${item.id}`, + })), + }; +}; diff --git a/lib/v2/hackertalk/maintainer.js b/lib/v2/hackertalk/maintainer.js new file mode 100644 index 0000000000..6077052813 --- /dev/null +++ b/lib/v2/hackertalk/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['hyoban'], +}; diff --git a/lib/v2/hackertalk/radar.js b/lib/v2/hackertalk/radar.js new file mode 100644 index 0000000000..5720927d22 --- /dev/null +++ b/lib/v2/hackertalk/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'hackertalk.net': { + _name: 'Hacker Talk 黑客说', + '.': [ + { + title: '最新的帖子', + docs: 'https://docs.rsshub.app/bbs.html#hacker-talk-hei-ke-shuo', + source: ['/?tab=new', '/'], + target: '/hackertalk', + }, + ], + }, +}; diff --git a/lib/v2/hackertalk/router.js b/lib/v2/hackertalk/router.js new file mode 100644 index 0000000000..20c52b09d7 --- /dev/null +++ b/lib/v2/hackertalk/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./index')); +};