fix(route/woshipm): fix article link generation and optimize parsing logic (#19098)
- Fix article link generation logic by using default value 'ai' when item.type is undefined - Optimize article parsing process by using Promise.allSettled to ensure partial failures don't block overall results
This commit is contained in:
parent
514962f3ba
commit
32047705a6
|
|
@ -47,13 +47,14 @@ async function handler(ctx) {
|
|||
return {
|
||||
title: item.articleTitle,
|
||||
description: item.articleSummary,
|
||||
link: `${baseUrl}/${item.type}/${item.id}.html`,
|
||||
link: `${baseUrl}/${item.type || 'ai'}/${item.id}.html`,
|
||||
pubDate: parseDate(item.publishTime, 'x'),
|
||||
author: item.articleAuthor,
|
||||
};
|
||||
});
|
||||
|
||||
const result = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
|
||||
const results = await Promise.allSettled(list.map((item) => parseArticle(item, cache.tryGet)));
|
||||
const result = results.filter((result) => result.status === 'fulfilled').map((result) => result.value);
|
||||
|
||||
return {
|
||||
title: `热门文章 - ${rangeMap[range]} - 人人都是产品经理`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue