fix(route/thepaper)(route/jiemian): remove useless image and audio (#21800)
* Comment out media object in rss_item Comment out media object in rss_item construction * Disable voiceInfo handling in RSS item Comment out voiceInfo handling logic in RSS item creation. * Update description extraction to exclude report view * Refactor description logic in common.tsx Refactor description extraction to remove specific images and report view paragraphs. * Handle missing featured image in description logic * Improve description extraction in common.tsx Refactor description extraction logic to handle cases without a featured image more cleanly.
This commit is contained in:
parent
51ef0df0c2
commit
37b70b48b6
|
|
@ -70,7 +70,23 @@ export const handler = async (ctx): Promise<Data> => {
|
|||
}
|
||||
: undefined,
|
||||
intro: content('div.article-header p').text(),
|
||||
description: content('div.article-content').html(),
|
||||
description: (() => {
|
||||
const featuredImageSrc = image.prop('src');
|
||||
if (!featuredImageSrc) {
|
||||
// 如果没有 featured image,直接返回原始内容
|
||||
const descContent = content('div.article-content').clone();
|
||||
descContent.find('p.report-view').remove();
|
||||
return descContent.html();
|
||||
}
|
||||
const baseImageName = featuredImageSrc.replace(/_[^.]+(\.\w+)$/, '$1');
|
||||
const descContent = content('div.article-content').clone();
|
||||
descContent.find('p.report-view').remove();
|
||||
if (baseImageName && baseImageName !== featuredImageSrc) {
|
||||
descContent.find(`img[src="${baseImageName}"]`).remove();
|
||||
}
|
||||
return descContent.html();
|
||||
})(),
|
||||
|
||||
});
|
||||
item.author = content('span.author')
|
||||
.first()
|
||||
|
|
|
|||
|
|
@ -61,20 +61,20 @@ export default {
|
|||
category: [...(contentDetail.tagList?.map((t) => t.tag) ?? []), contentDetail?.nodeInfo?.name ?? []],
|
||||
pubDate,
|
||||
author: contentDetail.author || '',
|
||||
media: {
|
||||
content: {
|
||||
url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic,
|
||||
},
|
||||
thumbnails: {
|
||||
url: item.sharePic || contentDetail.sharePic,
|
||||
},
|
||||
},
|
||||
// media: {
|
||||
// content: {
|
||||
// url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic,
|
||||
// },
|
||||
// thumbnails: {
|
||||
// url: item.sharePic || contentDetail.sharePic,
|
||||
// },
|
||||
// },
|
||||
};
|
||||
if (contentDetail.voiceInfo?.isHaveVoice) {
|
||||
rss_item.enclosure_type = 'audio/mpeg';
|
||||
rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc;
|
||||
rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl;
|
||||
}
|
||||
// if (contentDetail.voiceInfo?.isHaveVoice) {
|
||||
// rss_item.enclosure_type = 'audio/mpeg';
|
||||
// rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc;
|
||||
// rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl;
|
||||
// }
|
||||
return rss_item;
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue