commit
8fca0b6f1c
|
|
@ -5,7 +5,8 @@
|
|||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
|
|
@ -53,4 +54,4 @@
|
|||
"quotes": [1, "single"],
|
||||
"no-control-regex": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 北美票房榜
|
||||
- 煎蛋
|
||||
- 无聊图
|
||||
- GitHub
|
||||
- Releases
|
||||
|
||||
## 参与我们
|
||||
|
||||
|
|
|
|||
|
|
@ -70,4 +70,7 @@ router.get('/douban/movie/ustop', require('./routes/douban/ustop'));
|
|||
// 煎蛋
|
||||
router.get('/jandan/pic', require('./routes/jandan/pic'));
|
||||
|
||||
// GitHub
|
||||
router.get('/github/release/:owner/:repo', require('./routes/github/release'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const owner = ctx.params.owner;
|
||||
const repo = ctx.params.repo;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/releases`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
}
|
||||
});
|
||||
|
||||
const data = await Promise.all(response.data.map(async (item) => {
|
||||
let text = item.body;
|
||||
if (text) {
|
||||
// render github flavoured markdown
|
||||
const resp = await axios({
|
||||
method: 'post',
|
||||
url: 'https://api.github.com/markdown',
|
||||
data: {
|
||||
text,
|
||||
mode: 'gfm',
|
||||
context: `${owner}/${repo}`,
|
||||
},
|
||||
});
|
||||
text = resp.data;
|
||||
}
|
||||
return {
|
||||
title: `${item.name || item.tag_name}`,
|
||||
description: text,
|
||||
pubDate: new Date(item.published_at).toUTCString(),
|
||||
link: item.html_url,
|
||||
};
|
||||
}));
|
||||
|
||||
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${owner}/${repo} 的 Releases`,
|
||||
link: `https://github.com/${owner}/${repo}/releases`,
|
||||
description: `${owner}/${repo} 的 Releases`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data,
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue