@@ -2,9 +2,6 @@ const { join, resolve } = require('node:path');
22
33const clsx = require ( 'clsx' ) ;
44const { createApiPageMD, createInfoPageMD } = require ( 'docusaurus-plugin-openapi-docs/lib/markdown' ) ;
5- const { remark } = require ( 'remark' ) ;
6- const mdxRemoveImports = require ( 'remark-mdx-remove-imports' ) ;
7- const stripHtml = require ( 'remark-strip-html' ) ;
85
96const { config } = require ( './apify-docs-theme' ) ;
107const { collectSlugs } = require ( './tools/utils/collectSlugs' ) ;
@@ -365,19 +362,16 @@ module.exports = {
365362 ogImageURL . searchParams . set ( 'title' , result . frontMatter . title ) ;
366363 result . frontMatter . image ??= ogImageURL . toString ( ) ;
367364
368- const strip = ( await import ( 'strip-markdown' ) ) . default ; // ESM only
369- // const mdx = (await import('remark-mdx')).default; // ESM only
365+ // Remove import statements and JSX/MDX tags from content
366+ const contentText = result . content
367+ . replace ( / i m p o r t \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 ( ) ;
370372
371- // Use remark to strip markdown and get plain text
372- const processed = await remark ( )
373- . use ( stripHtml )
374- // .use(mdx)
375- . use ( mdxRemoveImports )
376- . use ( strip )
377- . process ( result . content ) ;
378- const contentText = String ( processed ) . replace ( / \s + / g, ' ' ) . trim ( ) ;
379- // Extract the first sentence (ending with . ! or ?) even if it spans multiple lines
380373 const sentenceMatch = contentText . match ( / ^ ( .* ?[ . ! ? ] ) \s / ) ;
374+
381375 result . frontMatter . description = sentenceMatch ? sentenceMatch [ 1 ] . trim ( ) : contentText ;
382376 }
383377
0 commit comments