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"