Skip to content

Commit 4f510f3

Browse files
authored
fix: Correct meta descriptions (#1911)
Closes #1870 Descriptions were split in the middle of the sentence as docusaurus took only first line. This PR introduces splitting by sentence. <img width="1099" height="98" alt="Screenshot 2025-09-09 at 16 45 39" src="https://github.com/user-attachments/assets/4e89413f-9a4d-4b6e-8b2a-04f21c081b8d" />
1 parent 3f3c74d commit 4f510f3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docusaurus.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,18 @@ module.exports = {
361361
const ogImageURL = new URL('https://apify.com/og-image/docs-article');
362362
ogImageURL.searchParams.set('title', result.frontMatter.title);
363363
result.frontMatter.image ??= ogImageURL.toString();
364+
365+
// Remove import statements and JSX/MDX tags from content
366+
const contentText = result.content
367+
.replace(/import\s+[^;]+;?/g, '') // Remove import statements
368+
.replace(/<[^>]+>/g, '') // Remove all tags (JSX/MDX)
369+
.replace(/\n+/g, ' ') // Replace newlines with space
370+
.replace(/\s+/g, ' ') // Collapse whitespace
371+
.trim();
372+
373+
const sentenceMatch = contentText.match(/^(.*?[.!?])\s/);
374+
375+
result.frontMatter.description = sentenceMatch ? sentenceMatch[1].trim() : contentText;
364376
}
365377

366378
return result;

package-lock.json

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

0 commit comments

Comments
 (0)