Include flag context in excerpt (#294)

* Added avoid flag text to meta descriptions

* Moved meta description logic to a shortcode

* Fixing nunjucks syntax error in base template head

Co-authored-by: Oscar <ovlb@users.noreply.github.com>
This commit is contained in:
Derek Murr
2020-09-01 15:39:23 -04:00
committed by GitHub
parent 019d80976d
commit 7aed7e3b90
5 changed files with 66 additions and 10 deletions

View File

@ -0,0 +1,16 @@
module.exports = function(preview, flag = {}) {
const initialCap = function(text) {
return `${text[0].toUpperCase()}${text.slice(1)}`;
};
if (flag && flag.level === 'avoid') {
if (flag.text) {
return `${initialCap(
flag.level
)}: ${flag.text.toLowerCase()}. ${initialCap(preview)}`;
}
return `${initialCap(flag.level)}: ${preview}`;
}
return initialCap(preview);
};