Skip to content

Commit

Permalink
fix(route): bbc incorrect section in title (#15502)
Browse files Browse the repository at this point in the history
* fix: incorrect section in title

* fix: remove String()
  • Loading branch information
HenryQW committed May 7, 2024
1 parent c0ded03 commit 5e2cbc1
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions lib/routes/bbc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,26 @@ async function handler(ctx) {

const $ = load(response);

const description = new URL(item.link).pathname.startsWith('/news/av') ? item.content : utils.ProcessFeed($);

let section = 'sport';
const urlSplit = item.link.split('/');
const sectionSplit = urlSplit.at(-1).split('-');
if (sectionSplit.length > 1) {
section = sectionSplit[0];
const path = new URL(item.link).pathname;

let description;

switch (true) {
case path.startsWith('/sport'):
description = item.content;
break;
case path.startsWith('/sounds/play'):
description = item.content;
break;
case path.startsWith('/news/live'):
description = item.content;
break;
default:
description = utils.ProcessFeed($);
}
section = section[0].toUpperCase() + section.slice(1);

return {
title: `[${section}] ${item.title}`,
title: item.title,
description,
pubDate: item.pubDate,
link: item.link,
Expand Down

0 comments on commit 5e2cbc1

Please sign in to comment.