diff --git a/docs/README.md b/docs/README.md index 1b77f7577..724a4a594 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1233,7 +1233,7 @@ since,时间跨度,可在 [Trending 页](https://github.com/trending/javascr language,语言,可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到 -### Issue +### Issue 举例: [https://rsshub.app/github/issue/DIYgod/RSSHub](https://rsshub.app/github/issue/DIYgod/RSSHub) diff --git a/package.json b/package.json index 8be2cd6cf..b505d33c1 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "koa-favicon": "2.0.1", "koa-router": "7.4.0", "lru-cache": "4.1.3", + "markdown-it": "^8.4.2", "path-to-regexp": "2.2.1", "readall": "1.0.0", "redis": "2.8.0", diff --git a/routes/github/issue.js b/routes/github/issue.js index 84c4df891..507047828 100644 --- a/routes/github/issue.js +++ b/routes/github/issue.js @@ -1,11 +1,12 @@ const axios = require('../../utils/axios'); const config = require('../../config'); +const md = require('markdown-it')(); module.exports = async (ctx) => { const user = ctx.params.user; const repo = ctx.params.repo; - const host = `https://github.com/repos/${user}/${repo}/issues`; + const host = `https://github.com/${user}/${repo}/issues`; const url = `https://api.github.com/repos/${user}/${repo}/issues`; const response = await axios({ @@ -20,16 +21,15 @@ module.exports = async (ctx) => { }, }); 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}`, - })), + item: data.filter((item) => item.pull_request === undefined).map((item) => ({ + title: item.title, + description: md.render(item.body) || 'No description', + pubDate: new Date(item.created_at), + link: `${host}/${item.number}`, + })), }; };