feat(route/apnews): Enhance support for video pages (#16347)

* feat(route/apnews): Enhance support for video pages

* Update lib/routes/apnews/utils.ts
This commit is contained in:
Andvari
2024-08-03 09:27:07 +08:00
committed by GitHub
parent e2f6c70290
commit d36d2a7021
+5 -4
View File
@@ -16,16 +16,17 @@ export function fetchArticle(item) {
}
const rawLdjson = JSON.parse($('#link-ld-json').text());
let ldjson;
if (Array.isArray(rawLdjson)) {
if (rawLdjson['@type'] === 'NewsArticle' || (Array.isArray(rawLdjson) && rawLdjson.some((e) => e['@type'] === 'NewsArticle'))) {
// Regular
ldjson = rawLdjson[0];
ldjson = Array.isArray(rawLdjson) ? rawLdjson.find((e) => e['@type'] === 'NewsArticle') : rawLdjson;
$('div.Enhancement').remove();
const section = $("meta[property='article:section']").attr('content');
return {
pubDate: parseDate(ldjson.datePublished),
updated: parseDate(ldjson.dateModified),
description: $('div.RichTextStoryBody').html(),
category: [`section:${$("meta[property='article:section']").attr('content')}`, ...(ldjson.keywords ?? [])],
description: $('div.RichTextStoryBody').html() || $(':is(.VideoLead, .VideoPage-pageSubHeading)').html(),
category: [...(section ? [section] : []), ...(ldjson.keywords ?? [])],
guid: $("meta[name='brightspot.contentId']").attr('content'),
author: ldjson.author,
...item,