added truncate feature to description function

This commit is contained in:
bill bittner 2017-12-21 12:01:05 -08:00
parent ac7d2b3bd9
commit 8b74ed680d

View file

@ -6,7 +6,12 @@ function determineOgTitle (storedTitle, defaultTitle) {
}; };
function determineOgDescription (storedDescription, defaultDescription) { function determineOgDescription (storedDescription, defaultDescription) {
return ifEmptyReturnOther(storedDescription, defaultDescription); const length = 200;
let description = ifEmptyReturnOther(storedDescription, defaultDescription);
if (description.length >= length) {
description = `${description.substring(0, length)}...`;
};
return description;
}; };
function ifEmptyReturnOther (value, replacement) { function ifEmptyReturnOther (value, replacement) {