Skip to content

Commit d787064

Browse files
committed
fix: Correct meta descriptions
1 parent 28303ea commit d787064

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docusaurus.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ module.exports = {
370370
result.frontMatter.image ??= ogImageURL.toString();
371371
}
372372

373+
// Extract the first sentence (ending with . ! or ?) even if it spans multiple lines
374+
const contentText = result.content.replace(/\n+/g, ' ').replace(/\s+/g, ' ').trim();
375+
const sentenceMatch = contentText.match(/^(.*?[.!?])\s/);
376+
result.frontMatter.description = sentenceMatch ? sentenceMatch[1].trim() : contentText;
377+
373378
return result;
374379
},
375380
},

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)