@devries-cameron20 / composio Mirror · read-only / commits / af5ac0418
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 12:00 UTC

feat(docs): Add markdown support for changelog pages

- Add PageActions component to changelog entry pages for copy/view markdown - Add /docs/changelog.md endpoint with index of all changelog entries - Add /docs/changelog/YYYY/MM/DD.md endpoints for individual entries Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 28, 2026 at 16:19 UTC af5ac0418213b17c32ce64fc16e9884d2bd2174d
2 files changed +173
docs/app/(home)/docs/changelog/[...slug]/page.tsx
+5
@@ -9,6 +9,7 @@ import {
9 import { notFound } from 'next/navigation';
10 import Link from 'next/link';
11 import { ChevronLeft } from 'lucide-react';
12 +import { PageActions } from '@/components/page-actions';
13
14 const mdxComponents = getMDXComponents();
15
@@ -33,6 +34,9 @@ export default async function ChangelogEntryPage({ params }: PageProps) {
34 notFound();
35 }
36
37 + // Build the path for PageActions (e.g., /docs/changelog/2026/01/07)
38 + const path = `/docs/changelog/${slug.join('/')}`;
39 +
40 // If there are multiple entries for the same date, show all of them
41 return (
42 <DocsPage toc={[]} footer={{ enabled: false }} tableOfContentPopover={{ enabled: false }}>
@@ -46,6 +50,7 @@ export default async function ChangelogEntryPage({ params }: PageProps) {
50
51 <DocsTitle>{formatDate(dateStr)}</DocsTitle>
52 <DocsDescription>Latest updates and announcements</DocsDescription>
53 + <PageActions path={path} />
54
55 <DocsBody>
56 <div className="space-y-12">
docs/app/llms.mdx/[[...slug]]/route.ts
+168
@@ -3,6 +3,9 @@ import {
3 getReferenceSource,
4 examplesSource,
5 toolkitsSource,
6 + changelogEntries,
7 + slugToDate,
8 + formatDate,
9 getLLMText,
10 } from '@/lib/source';
11 import { openapi } from '@/lib/openapi';
@@ -531,6 +534,141 @@ const sources = [
534 { prefix: 'toolkits', source: toolkitsSource },
535 ];
536
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 +
578 +/**
579 + * Generate a changelog index with links to all changelog entries.
580 + */
581 +function generateChangelogIndex(): string {
582 + // Group entries by date and sort by date descending (newest first)
583 + const entriesByDate = new Map<string, typeof changelogEntries>();
584 +
585 + for (const entry of changelogEntries) {
586 + const existing = entriesByDate.get(entry.date) || [];
587 + entriesByDate.set(entry.date, [...existing, entry]);
588 + }
589 +
590 + const sortedDates = Array.from(entriesByDate.keys()).sort((a, b) => b.localeCompare(a));
591 +
592 + const lines: string[] = [
593 + '# Changelog',
594 + '',
595 + 'All updates and announcements for Composio.',
596 + '',
597 + '| Date | Updates |',
598 + '|------|---------|',
599 + ];
600 +
601 + for (const date of sortedDates) {
602 + const entries = entriesByDate.get(date) || [];
603 + const [year, month, day] = date.split('-');
604 + const mdUrl = `/docs/changelog/${year}/${month}/${day}.md`;
605 + const formattedDate = formatDate(date);
606 + const titles = entries.map(e => e.title).join(', ');
607 + lines.push(`| [${formattedDate}](${mdUrl}) | ${titles} |`);
608 + }
609 +
610 + lines.push('');
611 + lines.push('---');
612 + lines.push('');
613 + lines.push('For the full changelog with details, visit each date above.');
614 +
615 + return lines.join('\n');
616 +}
617 +
618 +/**
619 + * Generate markdown for changelog entries matching a specific date.
620 + * Multiple entries on the same date are combined into one document.
621 + */
622 +async function changelogToMarkdown(dateStr: string): Promise<string | null> {
623 + const matchingEntries = changelogEntries.filter(
624 + (entry) => entry.date === dateStr
625 + );
626 +
627 + if (matchingEntries.length === 0) {
628 + return null;
629 + }
630 +
631 + const formattedDate = formatDate(dateStr);
632 + const lines: string[] = [
633 + `# Changelog - ${formattedDate}`,
634 + '',
635 + `**Documentation:** /docs/changelog/${dateStr.replace(/-/g, '/')}`,
636 + '',
637 + ];
638 +
639 + for (const entry of matchingEntries) {
640 + lines.push(`## ${entry.title}`, '');
641 +
642 + if (entry.description) {
643 + lines.push(entry.description, '');
644 + }
645 +
646 + // Try to get the processed text if available
647 + if (typeof entry.getText === 'function') {
648 + try {
649 + const text = await entry.getText('processed');
650 + if (text) {
651 + lines.push(mdxToCleanMarkdown(text), '');
652 + }
653 + } catch {
654 + // getText not available, try raw
655 + try {
656 + const text = await entry.getText('raw');
657 + if (text) {
658 + lines.push(mdxToCleanMarkdown(text), '');
659 + }
660 + } catch {
661 + // No text available, just use title/description
662 + }
663 + }
664 + }
665 +
666 + lines.push('---', '');
667 + }
668 +
669 + return lines.join('\n').trim();
670 +}
671 +
672 // Format parameter type with enum values if available
673 function formatParamType(param: ParameterSchema): string {
674 let typeStr = param.type || 'string';
@@ -706,6 +844,36 @@ export async function GET(
844 });
845 }
846
847 + // Special handling for changelog index - /docs/changelog
848 + if (prefix === 'docs' && rest[0] === 'changelog' && rest.length === 1) {
849 + const changelogIndex = generateChangelogIndex();
850 + return new Response(changelogIndex, {
851 + headers: {
852 + 'Content-Type': 'text/markdown; charset=utf-8',
853 + },
854 + });
855 + }
856 +
857 + // Special handling for changelog pages - /docs/changelog/YYYY/MM/DD
858 + if (prefix === 'docs' && rest[0] === 'changelog' && rest.length === 4) {
859 + // rest = ['changelog', '2026', '01', '07']
860 + const [, year, month, day] = rest;
861 + const dateStr = slugToDate([year, month, day]);
862 +
863 + if (dateStr) {
864 + const markdown = await changelogToMarkdown(dateStr);
865 + if (markdown) {
866 + return new Response(markdown, {
867 + headers: {
868 + 'Content-Type': 'text/markdown; charset=utf-8',
869 + },
870 + });
871 + }
872 + }
873 + // If no entries found, fall through to notFound
874 + notFound();
875 + }
876 +
877 // Handle 'reference' specially - uses async getReferenceSource() for OpenAPI pages
878 // eslint-disable-next-line @typescript-eslint/no-explicit-any
879 let pageSource: any;