diff --git a/docusaurus.config.js b/docusaurus.config.js index 3ee38ccb6d..3629fec129 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -361,6 +361,18 @@ module.exports = { const ogImageURL = new URL('https://apify.com/og-image/docs-article'); ogImageURL.searchParams.set('title', result.frontMatter.title); result.frontMatter.image ??= ogImageURL.toString(); + + // Remove import statements and JSX/MDX tags from content + const contentText = result.content + .replace(/import\s+[^;]+;?/g, '') // Remove import statements + .replace(/<[^>]+>/g, '') // Remove all tags (JSX/MDX) + .replace(/\n+/g, ' ') // Replace newlines with space + .replace(/\s+/g, ' ') // Collapse whitespace + .trim(); + + const sentenceMatch = contentText.match(/^(.*?[.!?])\s/); + + result.frontMatter.description = sentenceMatch ? sentenceMatch[1].trim() : contentText; } return result; diff --git a/package-lock.json b/package-lock.json index 07f0d933db..9a3b8be691 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26754,6 +26754,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.1.1.tgz", "integrity": "sha512-Pjj2IYlUY3+D8x00UJsIOg5BEvfMyeI+2uLPn9VO9Wg4MEtN/VTIq2NEJQfde9PnX15KgtHyl9S0BcTnWrIuWg==", + "license": "MIT", "dependencies": { "mdast-util-mdx": "^3.0.0", "micromark-extension-mdxjs": "^3.0.0"