From 7b38114b2ef982b5a962ff9caff7dd0baf624318 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sat, 16 Dec 2023 20:46:52 +1030 Subject: [PATCH] Fixes to summary --- lib/common.js | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/common.js b/lib/common.js index 99913a0..1987ac4 100644 --- a/lib/common.js +++ b/lib/common.js @@ -35,8 +35,13 @@ markdown.use(markdownItAttrs, { allowedAttributes: ['id', 'class', /^regex.*$/] }); -const getSummary = (body) => { - let summary = stripHtml(body).result; +const getSummary = (meta) => { + // Check for summary in Meta and return timmed + if(meta.summary){ + return trimSummary(meta.summary, process.config.summaryLength || 250); + } + // If no summary, grab from the body + let summary = stripHtml(meta.body).result; summary = summary.replace(/(\r\n|\n|\r)/gm, ''); return trimSummary(summary, process.config.summaryLength || 250); }; @@ -87,7 +92,7 @@ const getMeta = async (filepath) => { meta.date = frontMatter.dateObject; meta.fileMeta.date = frontMatter.dateObject; meta.lastupdated = frontMatter.lastupdated; - meta.summary = getSummary(meta.body); + meta.summary = getSummary(meta); meta.readingTime = readingTime(meta.body); meta.url = `${process.config.baseUrl}/${meta.permalink}`; if(meta.permalink.slice(-1) !== '/'){ diff --git a/package.json b/package.json index 9b8fc4a..9e681cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squido", - "version": "1.0.25", + "version": "1.0.26", "description": "A dead-simple static HTML website generator for super fast static websites which are easier to develop, more secure and dirt cheaper to host.", "bin": { "squido": "cli.js"