Skip to content

Commit

Permalink
shorten unfurl description a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
marwie committed Jul 30, 2023
1 parent 830e9a5 commit caf731c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions documentation/.vuepress/plugins/html-meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,15 @@ async function generateOgImageUrl(ogImage, title, description, pageFilePath) {
description = description.replace(/"/g, '\'');
description = description.replace(/\n/g, ' ');
description = description.replace("---", '');
const maxLength = 600;
if (description.length > maxLength) description = description.substring(0, maxLength) + "...";
const maxLength = 400;
if (description.length > maxLength) {
description = description.substring(0, maxLength);
const lastEndOfSentence = description.lastIndexOf(".");
if (lastEndOfSentence > 0) {
description = description.substring(0, lastEndOfSentence);
}
else description += "...";
}
description = description.trim();
if (description.length <= 0) {
console.warn("?? No description for og image", originalTitle, "at", pageFilePath);
Expand Down

0 comments on commit caf731c

Please sign in to comment.