Skip to content

Commit

Permalink
feat(chinacdc): empty title
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Dec 31, 2024
1 parent 336464d commit 4561197
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/routes/chinacdc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const handler = async (ctx: Context): Promise<Data> => {

const aEl: Cheerio<Element> = $item.find('a');

const title: string = aEl.prop('title') || aEl.text();
const title: string = aEl.prop('title') === undefined ? aEl.text() : aEl.prop('title');

const description: string = art(path.join(__dirname, 'templates/description.art'), {
intro: $item.find('p.zy').text(),
Expand Down Expand Up @@ -74,13 +74,13 @@ export const handler = async (ctx: Context): Promise<Data> => {
const detailResponse = await ofetch(item.link);
const $$: CheerioAPI = load(detailResponse);

const title: string = $$('h5').text();
const detailTitle: string = $$('h5').text();
const description: string = art(path.join(__dirname, 'templates/description.art'), {
description: $$('div.TRS_Editor').html(),
});

return {
title,
title: detailTitle || item.title, // Use original title as fallback
description,
link: item.link,
pubDate: parseDate($$('span.fb em').text()),
Expand Down

0 comments on commit 4561197

Please sign in to comment.