mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 02:28:23 +08:00
fix(route): github recent issues (#9473)
This commit is contained in:
@@ -5,17 +5,19 @@ const md = require('markdown-it')({
|
|||||||
linkify: true,
|
linkify: true,
|
||||||
});
|
});
|
||||||
const queryString = require('query-string');
|
const queryString = require('query-string');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const user = ctx.params.user;
|
const user = ctx.params.user;
|
||||||
const repo = ctx.params.repo;
|
const repo = ctx.params.repo;
|
||||||
const state = ctx.params.state;
|
const state = ctx.params.state;
|
||||||
const labels = ctx.params.labels;
|
const labels = ctx.params.labels;
|
||||||
|
const limit = ctx.query.limit ? (parseInt(ctx.query.limit) > 100 ? 100 : parseInt(ctx.query.limit)) : 100;
|
||||||
|
|
||||||
const host = `https://github.com/${user}/${repo}/issues`;
|
const host = `https://github.com/${user}/${repo}/issues`;
|
||||||
const url = `https://api.github.com/repos/${user}/${repo}/issues`;
|
const url = `https://api.github.com/repos/${user}/${repo}/issues`;
|
||||||
|
|
||||||
const headers = {};
|
const headers = { Accept: 'application/vnd.github.v3+json' };
|
||||||
if (config.github && config.github.access_token) {
|
if (config.github && config.github.access_token) {
|
||||||
headers.Authorization = `token ${config.github.access_token}`;
|
headers.Authorization = `token ${config.github.access_token}`;
|
||||||
}
|
}
|
||||||
@@ -26,6 +28,8 @@ module.exports = async (ctx) => {
|
|||||||
state,
|
state,
|
||||||
labels,
|
labels,
|
||||||
sort: 'created',
|
sort: 'created',
|
||||||
|
direction: 'desc',
|
||||||
|
per_page: limit,
|
||||||
}),
|
}),
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
@@ -40,7 +44,7 @@ module.exports = async (ctx) => {
|
|||||||
.map((item) => ({
|
.map((item) => ({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.body ? md.render(item.body) : 'No description',
|
description: item.body ? md.render(item.body) : 'No description',
|
||||||
pubDate: new Date(item.created_at).toUTCString(),
|
pubDate: parseDate(item.created_at),
|
||||||
author: item.user.login,
|
author: item.user.login,
|
||||||
link: `${host}/${item.number}`,
|
link: `${host}/${item.number}`,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
|
|||||||
const host = `https://github.com/${user}/${repo}/pulls`;
|
const host = `https://github.com/${user}/${repo}/pulls`;
|
||||||
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
||||||
|
|
||||||
const headers = {};
|
const headers = { Accept: 'application/vnd.github.v3+json' };
|
||||||
if (config.github && config.github.access_token) {
|
if (config.github && config.github.access_token) {
|
||||||
headers.Authorization = `token ${config.github.access_token}`;
|
headers.Authorization = `token ${config.github.access_token}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user