From b5ad2fa0cb08e4a718285de575a97b107152eea1 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Tue, 3 Sep 2024 03:08:00 +0800 Subject: [PATCH] fix(route/picnob/user): missing linebreak (#16608) Signed-off-by: Rongrong --- lib/routes/picnob/user.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/routes/picnob/user.ts b/lib/routes/picnob/user.ts index 5970728dc..617628431 100644 --- a/lib/routes/picnob/user.ts +++ b/lib/routes/picnob/user.ts @@ -82,7 +82,8 @@ async function handler(ctx) { const list = await Promise.all( posts.items.map(async (item) => { - const { shortcode, type, sum_pure, time } = item; + const { shortcode, sum, type, time } = item; + const link = `${baseUrl}/post/${shortcode}/`; if (type === 'img_multi') { item.images = await cache.tryGet(link, async () => { @@ -111,8 +112,15 @@ async function handler(ctx) { } return { - title: sum_pure, - description: art(path.join(__dirname, 'templates/desc.art'), { item }), + // sum_pure lacks linebreaks/spaces between lines + title: load(sum, null, false).text().replaceAll('\n', ' '), + description: art(path.join(__dirname, 'templates/desc.art'), { + item: { + ...item, + // Fix linebreaks + sum: sum.replaceAll('\n', '
'), + }, + }), link, pubDate: parseDate(time, 'X'), };