diff --git a/README.md b/README.md index 8943d77721..53327a5bab 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 分类 - GitHub - 用户仓库 + - Trending + - Issue - Konachan.com Anime Wallpapers - posts - Popular Recent Posts diff --git a/docs/README.md b/docs/README.md index 54b173f910..f6535c215b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1165,6 +1165,15 @@ since,时间跨度,可在 [Trending 页](https://github.com/trending/javascr language,语言,可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到 +### Issue + +举例: [https://rsshub.app/github/issue/DIYgod/RSSHub](https://rsshub.app/github/issue/DIYgod/RSSHub) + +路由: `/github/issue/:user/:repo` + +参数: user,用户名 +参数: repo,仓库名 + ## 纽约时报 ::: tip 提示 diff --git a/router.js b/router.js index df31e61fea..831cb49680 100755 --- a/router.js +++ b/router.js @@ -263,6 +263,7 @@ if (config.github && config.github.access_token) { logger.warn('GitHub Repos RSS is disabled for lacking config.'); } router.get('/github/trending/:since/:language?', require('./routes/github/trending')); +router.get('/github/issue/:user/:repo', require('./routes/github/issue')); // konachan router.get('/konachan/post', require('./routes/konachan/post')); diff --git a/routes/github/issue.js b/routes/github/issue.js new file mode 100644 index 0000000000..84c4df891d --- /dev/null +++ b/routes/github/issue.js @@ -0,0 +1,35 @@ +const axios = require('../../utils/axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const user = ctx.params.user; + const repo = ctx.params.repo; + + const host = `https://github.com/repos/${user}/${repo}/issues`; + const url = `https://api.github.com/repos/${user}/${repo}/issues`; + + const response = await axios({ + method: 'get', + url, + headers: { + 'User-Agent': config.ua, + }, + params: { + sort: 'created', + access_token: config.github.access_token, + }, + }); + const data = response.data; + ctx.state.data = { + title: `${user}/${repo} Issues`, + link: host, + item: + data && + data.map((item) => ({ + title: item.title, + description: item.body || 'No description', + pubDate: new Date(item.created_at), + link: `${host}/${item.number}`, + })), + }; +};