Skip to content

Commit

Permalink
Fixes to summary
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvautin committed Dec 16, 2023
1 parent 00c00bd commit 7b38114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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) !== '/'){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 7b38114

Please sign in to comment.