mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
fix(route): HelloGitHub月刊 (#11226)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const md = require('markdown-it')({
|
||||
@@ -11,12 +10,8 @@ art.defaults.imports.render = function (string) {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
||||
|
||||
const rootUrl = 'https://hellogithub.com';
|
||||
const apiRootUrl = 'https://api.hellogithub.com';
|
||||
const currentUrl = `${rootUrl}/periodical/volume/`;
|
||||
const apiUrl = `${apiRootUrl}/v1/volume/all/`;
|
||||
|
||||
const buildResponse = await got({
|
||||
method: 'get',
|
||||
@@ -25,38 +20,26 @@ module.exports = async (ctx) => {
|
||||
|
||||
const buildId = buildResponse.data.match(/"buildId":"(.*?)",/)[1];
|
||||
|
||||
const apiUrl = `${rootUrl}/_next/data/${buildId}/periodical/volume.json`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items = response.data.data.slice(0, limit).map((item) => ({
|
||||
guid: item.num,
|
||||
title: `No.${item.num}`,
|
||||
link: `${rootUrl}/periodical/volume/${item.guid}`,
|
||||
}));
|
||||
const data = response.data;
|
||||
const id = data.pageProps.volume.current_num;
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailUrl = `${rootUrl}/_next/data/${buildId}/periodical/volume/${item.guid}.json`;
|
||||
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: detailUrl,
|
||||
});
|
||||
|
||||
const data = detailResponse.data;
|
||||
|
||||
item.pubDate = parseDate(data.pageProps.volume.publish_at);
|
||||
item.description = art(path.join(__dirname, 'templates/volume.art'), {
|
||||
data: data.pageProps.volume.data,
|
||||
});
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
const items = [
|
||||
{
|
||||
guid: id,
|
||||
title: `No.${id}`,
|
||||
link: `${rootUrl}/periodical/volume/${id}`,
|
||||
description: art(path.join(__dirname, 'templates/volume.art'), {
|
||||
data: data.pageProps.volume.data,
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'HelloGithub - 月刊',
|
||||
|
||||
Reference in New Issue
Block a user