Skip to content

Commit 37b70b4

Browse files
author
HamadaMasatoshi
authored
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.
1 parent 51ef0df commit 37b70b4

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

lib/routes/jiemian/common.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,23 @@ export const handler = async (ctx): Promise<Data> => {
7070
}
7171
: undefined,
7272
intro: content('div.article-header p').text(),
73-
description: content('div.article-content').html(),
73+
description: (() => {
74+
const featuredImageSrc = image.prop('src');
75+
if (!featuredImageSrc) {
76+
// 如果没有 featured image,直接返回原始内容
77+
const descContent = content('div.article-content').clone();
78+
descContent.find('p.report-view').remove();
79+
return descContent.html();
80+
}
81+
const baseImageName = featuredImageSrc.replace(/_[^.]+(\.\w+)$/, '$1');
82+
const descContent = content('div.article-content').clone();
83+
descContent.find('p.report-view').remove();
84+
if (baseImageName && baseImageName !== featuredImageSrc) {
85+
descContent.find(`img[src="${baseImageName}"]`).remove();
86+
}
87+
return descContent.html();
88+
})(),
89+
7490
});
7591
item.author = content('span.author')
7692
.first()

lib/routes/thepaper/utils.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ export default {
6161
category: [...(contentDetail.tagList?.map((t) => t.tag) ?? []), contentDetail?.nodeInfo?.name ?? []],
6262
pubDate,
6363
author: contentDetail.author || '',
64-
media: {
65-
content: {
66-
url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic,
67-
},
68-
thumbnails: {
69-
url: item.sharePic || contentDetail.sharePic,
70-
},
71-
},
64+
// media: {
65+
// content: {
66+
// url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic,
67+
// },
68+
// thumbnails: {
69+
// url: item.sharePic || contentDetail.sharePic,
70+
// },
71+
// },
7272
};
73-
if (contentDetail.voiceInfo?.isHaveVoice) {
74-
rss_item.enclosure_type = 'audio/mpeg';
75-
rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc;
76-
rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl;
77-
}
73+
// if (contentDetail.voiceInfo?.isHaveVoice) {
74+
// rss_item.enclosure_type = 'audio/mpeg';
75+
// rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc;
76+
// rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl;
77+
// }
7878
return rss_item;
7979
});
8080
},

0 commit comments

Comments
 (0)