feat(route/apnews): Enhance parsing when not fetching full text. (#16750)

This commit is contained in:
Andvari
2024-09-14 23:07:26 +08:00
committed by GitHub
parent 0605590d41
commit 1418f35d7b
2 changed files with 7 additions and 1 deletions
+6 -1
View File
@@ -44,14 +44,19 @@ async function handler(ctx) {
title: e.contents[0]?.headline,
link: e.contents[0]?.localLinkUrl,
pubDate: timezone(parseDate(e.publishedDate), 0),
category: e.tagObjs.map((tag) => tag.name),
updated: timezone(parseDate(e.contents[0]?.updated), 0),
description: e.contents[0]?.storyHTML,
author: e.contents[0]?.reporters.map((author) => ({ name: author.displayName })),
}))
.sort((a, b) => b.pubDate - a.pubDate)
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20);
const items = await Promise.all(list.map((item) => fetchArticle(item)));
const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(list.map((item) => fetchArticle(item))) : list;
return {
title: `${res.tagObjs[0].name} - AP News`,
item: items,
link: 'https://apnews.com',
};
}
+1
View File
@@ -87,6 +87,7 @@ async function handler(ctx) {
return {
title: `AP News sitemap:${route}`,
item: items,
link: 'https://apnews.com',
};
}
async function asyncPoolAll<IN, OUT>(poolLimit: number, array: readonly IN[], iteratorFn: (generator: IN) => Promise<OUT>) {