Skip to content

Commit

Permalink
feat(route/apnews): Enhance support for video pages (#16347)
Browse files Browse the repository at this point in the history
* feat(route/apnews): Enhance support for video pages

* Update lib/routes/apnews/utils.ts
  • Loading branch information
dzx-dzx authored Aug 3, 2024
1 parent e2f6c70 commit d36d2a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/routes/apnews/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d36d2a7

Please sign in to comment.