Skip to content

Commit

Permalink
fix(route/apnews): Fix page (#15808)
Browse files Browse the repository at this point in the history
* fix(route/apnews): Fix page.

* .
  • Loading branch information
dzx-dzx authored Jun 3, 2024
1 parent 7175ab0 commit 4cf8b28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/routes/apnews/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function handler(ctx) {
link: $(e).find('a').attr('href'),
}))
.filter((e) => typeof e.link === 'string')
.map((item) => (new URL(item.link).hostname === 'apnews.com' ? fetchArticle(item) : item))
.map((item) => fetchArticle(item))
);

return {
Expand Down
3 changes: 3 additions & 0 deletions lib/routes/apnews/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export function fetchArticle(item) {
return cache.tryGet(item.link, async () => {
const data = await ofetch(item.link);
const $ = load(data);
if ($('#link-ld-json').length === 0) {
return item;
}
const rawLdjson = JSON.parse($('#link-ld-json').text());
let ldjson;
if (Array.isArray(rawLdjson)) {
Expand Down

0 comments on commit 4cf8b28

Please sign in to comment.