Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
refactor(docs): Remove duplicate mdxToCleanMarkdown function
Export the comprehensive mdxToCleanMarkdown from lib/source.ts and import it in route.ts instead of maintaining a simplified duplicate. This ensures changelog markdown gets the same high-quality conversion as other docs pages (YouTube links, Figure captions, Steps, Cards, etc). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 28, 2026 at 16:36 UTC
5bd12eb176d06807d1414a3e27108f7183dd7b4f
2 files changed
+2
-42
docs/app/llms.mdx/[[...slug]]/route.ts
+1
-41
@@ -7,6 +7,7 @@ import {
7
slugToDate,
8
formatDate,
9
getLLMText,
10
+ mdxToCleanMarkdown,
11
} from '@/lib/source';
12
import { openapi } from '@/lib/openapi';
13
import { notFound } from 'next/navigation';
@@ -534,47 +535,6 @@ const sources = [
535
{ prefix: 'toolkits', source: toolkitsSource },
536
];
537
537
-/**
538
- * Strips MDX-specific syntax from content for clean markdown output.
539
- * Converts JSX components to plain text equivalents.
540
- */
541
-function mdxToCleanMarkdown(content: string): string {
542
- let result = content;
543
-
544
- // Remove frontmatter
545
- result = result.replace(/^---[\s\S]*?---\n*/m, '');
546
-
547
- // Convert Accordion to collapsible-style text
548
- result = result.replace(
549
- /<Accordion[\s\S]*?title="([^"]*)"[\s\S]*?>([\s\S]*?)<\/Accordion>/g,
550
- '\n**$1**\n$2'
551
- );
552
-
553
- // Convert Callout to blockquote
554
- result = result.replace(
555
- /<Callout[^>]*title="([^"]*)"[^>]*>([\s\S]*?)<\/Callout>/g,
556
- (_, title, calloutContent) => `> **${title}**: ${calloutContent.trim()}`
557
- );
558
- result = result.replace(
559
- /<Callout[^>]*>([\s\S]*?)<\/Callout>/g,
560
- (_, calloutContent) => `> ${calloutContent.trim()}`
561
- );
562
-
563
- // Remove wrapper components
564
- result = result.replace(/<\/?(Accordions|Cards|Tabs)[^>]*>/g, '');
565
-
566
- // Remove remaining self-closing JSX tags
567
- result = result.replace(/<[A-Z][a-zA-Z]*[\s\S]*?\/>/g, '');
568
-
569
- // Remove remaining JSX opening/closing tags but keep content
570
- result = result.replace(/<\/?[A-Z][a-zA-Z]*[^>]*>/g, '');
571
-
572
- // Clean up excessive newlines
573
- result = result.replace(/\n{3,}/g, '\n\n');
574
-
575
- return result.trim();
576
-}
577
-
538
/**
539
* Generate a changelog index with links to all changelog entries.
540
*/
docs/lib/source.ts
+1
-1
@@ -76,7 +76,7 @@ export function getOgImageUrl(_section: string, _slugs: string[], title?: string
76
* Converts MDX content to clean markdown for AI agents.
77
* Strips JSX components and converts them to plain text equivalents.
78
*/
79
-function mdxToCleanMarkdown(content: string): string {
79
+export function mdxToCleanMarkdown(content: string): string {
80
let result = content;
81
82
// Remove frontmatter