From 07508faf1a3a20f7118f4f6b99ffc26e7d30d693 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 25 Aug 2022 19:31:48 +0100 Subject: [PATCH] fix overlength summaries --- src/index.11tydata.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.11tydata.js b/src/index.11tydata.js index 46bf67b..28c0bbc 100644 --- a/src/index.11tydata.js +++ b/src/index.11tydata.js @@ -69,9 +69,16 @@ async function do_feeds() { item.content = item.summary; } - if(!item.description - || (typeof item.description == "string" && item.description.length === 0)) item.description = striptags(item.content) - .substring(0, DESCRIPTION_LENGTH); + if(typeof item.description !== "string") { + if(typeof item.summary === "string") + item.description = item.summary; + else if(typeof item.content === "string") + item.description = item.content; + } + + item.description = striptags(item.content) + .substring(0, DESCRIPTION_LENGTH); + if(!item.pubdate) item.pubdate = item.published || item.updated