Skip to content

Commit 7f28bd0

Browse files
committed
fix: debug remark
1 parent 12a6cf0 commit 7f28bd0

File tree

3 files changed

+81
-8
lines changed

3 files changed

+81
-8
lines changed

docusaurus.config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const { join, resolve } = require('node:path');
22

33
const clsx = require('clsx');
44
const { createApiPageMD, createInfoPageMD } = require('docusaurus-plugin-openapi-docs/lib/markdown');
5+
const remark = require('remark');
6+
const strip = require('strip-markdown');
57

68
const { config } = require('./apify-docs-theme');
79
const { collectSlugs } = require('./tools/utils/collectSlugs');
@@ -362,13 +364,9 @@ module.exports = {
362364
ogImageURL.searchParams.set('title', result.frontMatter.title);
363365
result.frontMatter.image ??= ogImageURL.toString();
364366

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();
367+
// Use remark to strip markdown and get plain text
368+
const processed = await remark().use(strip).process(result.content);
369+
const contentText = String(processed).replace(/\s+/g, ' ').trim();
372370
// Extract the first sentence (ending with . ! or ?) even if it spans multiple lines
373371
const sentenceMatch = contentText.match(/^(.*?[.!?])\s/);
374372
result.frontMatter.description = sentenceMatch ? sentenceMatch[1].trim() : contentText;

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"markdownlint-cli": "^0.45.0",
6363
"patch-package": "^8.0.0",
6464
"path-browserify": "^1.0.1",
65+
"remark": "^15.0.1",
6566
"rimraf": "^6.0.0",
67+
"strip-markdown": "^6.0.0",
6668
"typescript": "5.9.2",
6769
"typescript-eslint": "^8.38.0"
6870
},

0 commit comments

Comments
 (0)