From 0e8ea120eaa8bf2ce3d29e92f8673eb8ce36b2b5 Mon Sep 17 00:00:00 2001 From: Eson Wong Date: Fri, 28 Aug 2026 11:37:09 +0800 Subject: [PATCH] fix(route/latepost): include cover image and abstract in description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The article body selector `#select-main` excludes the cover image, which the site renders in a sibling block. As a result feed items never carried the cover, even though every recent exclusive and long read has one. Pick it up from `#abstract_img` (exclusives, long reads) or `img.interview-pic` (interviews), falling back to the share image declared in the page script so both layouts are covered. The site serves these over plain http, so upgrade the scheme — readers on https tend to refuse mixed content. Articles genuinely without a cover, such as those in the 晚点早知道 column, are left untouched. Also prepend the one-line abstract that accompanies the cover, which was likewise dropped. Co-Authored-By: Claude Opus 5 --- lib/routes/latepost/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/routes/latepost/index.ts b/lib/routes/latepost/index.ts index 421c88478ada..f1b6b2a3fdfe 100644 --- a/lib/routes/latepost/index.ts +++ b/lib/routes/latepost/index.ts @@ -94,7 +94,21 @@ async function handler(ctx): Promise { const content = load(detailResponse); item.title ??= content('div.article-header-title').text(); - item.description = content('#select-main').html()!.replaceAll('


', ''); + + // The cover image lives outside of the article body (#select-main), in either the + // `.abstract` block (exclusives / long reads) or `.interview-pic` (interviews). + // Fall back to the share image embedded in the page script, which covers both layouts. + let cover = content('#abstract_img').attr('src') || content('img.interview-pic').attr('src'); + if (!cover) { + cover = /var\s+imgUrl\s*=\s*'([^']+)'/.exec(detailResponse)?.[1]; + } + // The site serves the cover over plain http, which readers may refuse to load. + const coverHtml = cover ? `` : ''; + + const abstract = content('div.abstract-pic-left').text().trim(); + const abstractHtml = abstract ? `
${abstract}
` : ''; + + item.description = coverHtml + abstractHtml + content('#select-main').html()!.replaceAll('


', ''); item.author = content('div.article-header-author div.author-link a.label').first().text(); item.category = item.category.filter(Boolean); item.guid = `latepost-${item.guid}`;