mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 18:48:12 +08:00
fix(route): github recent issues (#9473)
This commit is contained in:
@@ -5,17 +5,19 @@ const md = require('markdown-it')({
|
||||
linkify: true,
|
||||
});
|
||||
const queryString = require('query-string');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
const repo = ctx.params.repo;
|
||||
const state = ctx.params.state;
|
||||
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 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) {
|
||||
headers.Authorization = `token ${config.github.access_token}`;
|
||||
}
|
||||
@@ -26,6 +28,8 @@ module.exports = async (ctx) => {
|
||||
state,
|
||||
labels,
|
||||
sort: 'created',
|
||||
direction: 'desc',
|
||||
per_page: limit,
|
||||
}),
|
||||
headers,
|
||||
});
|
||||
@@ -40,7 +44,7 @@ module.exports = async (ctx) => {
|
||||
.map((item) => ({
|
||||
title: item.title,
|
||||
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,
|
||||
link: `${host}/${item.number}`,
|
||||
})),
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
|
||||
const host = `https://github.com/${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) {
|
||||
headers.Authorization = `token ${config.github.access_token}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user