@devries-cameron20 / composio Mirror · read-only / commits / 56ec74e23
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, 14:30 UTC

refactor(docs): simplify .md routes with single catch-all

Replace 4 separate routes + 16 rewrites with: - 1 unified route that handles all sources - 2 rewrite rules: /:path*.md and /:path*.mdx Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 19, 2026 at 15:22 UTC 56ec74e23c72e55061f0d93220b17d9292c7d74d
6 files changed +55 -116
docs/app/llms.mdx/[[...slug]]/route.ts new
+52
@@ -0,0 +1,52 @@
1 +import {
2 + source,
3 + toolRouterSource,
4 + referenceSource,
5 + examplesSource,
6 + getLLMText,
7 +} from '@/lib/source';
8 +import { notFound } from 'next/navigation';
9 +
10 +export const revalidate = false;
11 +
12 +// Map URL prefixes to their sources
13 +const sources = [
14 + { prefix: 'docs', source },
15 + { prefix: 'tool-router', source: toolRouterSource },
16 + { prefix: 'reference', source: referenceSource },
17 + { prefix: 'examples', source: examplesSource },
18 +];
19 +
20 +export async function GET(
21 + _req: Request,
22 + { params }: { params: Promise<{ slug?: string[] }> }
23 +) {
24 + const { slug = [] } = await params;
25 + const [prefix, ...rest] = slug;
26 +
27 + // Find the matching source
28 + const match = sources.find((s) => s.prefix === prefix);
29 + if (!match) notFound();
30 +
31 + // Get the page from that source
32 + const page = match.source.getPage(rest.length > 0 ? rest : undefined);
33 + if (!page) notFound();
34 +
35 + try {
36 + return new Response(await getLLMText(page), {
37 + headers: {
38 + 'Content-Type': 'text/markdown; charset=utf-8',
39 + },
40 + });
41 + } catch {
42 + // Graceful fallback
43 + return new Response(
44 + `# ${page.data.title} (${page.url})\n\n${page.data.description || ''}`,
45 + {
46 + headers: {
47 + 'Content-Type': 'text/markdown; charset=utf-8',
48 + },
49 + }
50 + );
51 + }
52 +}
docs/app/llms.mdx/docs/[[...slug]]/route.ts deleted
-23
@@ -1,23 +0,0 @@
1 -import { getLLMText, source } from '@/lib/source';
2 -import { notFound } from 'next/navigation';
3 -
4 -export const revalidate = false;
5 -
6 -export async function GET(
7 - _req: Request,
8 - { params }: { params: Promise<{ slug?: string[] }> }
9 -) {
10 - const { slug } = await params;
11 - const page = source.getPage(slug);
12 - if (!page) notFound();
13 -
14 - return new Response(await getLLMText(page), {
15 - headers: {
16 - 'Content-Type': 'text/markdown; charset=utf-8',
17 - },
18 - });
19 -}
20 -
21 -export function generateStaticParams() {
22 - return source.generateParams();
23 -}
docs/app/llms.mdx/examples/[[...slug]]/route.ts deleted
-24
@@ -1,24 +0,0 @@
1 -import { examplesSource } from '@/lib/source';
2 -import { getLLMText } from '@/lib/source';
3 -import { notFound } from 'next/navigation';
4 -
5 -export const revalidate = false;
6 -
7 -export async function GET(
8 - _req: Request,
9 - { params }: { params: Promise<{ slug?: string[] }> }
10 -) {
11 - const { slug } = await params;
12 - const page = examplesSource.getPage(slug);
13 - if (!page) notFound();
14 -
15 - return new Response(await getLLMText(page), {
16 - headers: {
17 - 'Content-Type': 'text/markdown; charset=utf-8',
18 - },
19 - });
20 -}
21 -
22 -export function generateStaticParams() {
23 - return examplesSource.generateParams();
24 -}
docs/app/llms.mdx/reference/[[...slug]]/route.ts deleted
-24
@@ -1,24 +0,0 @@
1 -import { referenceSource } from '@/lib/source';
2 -import { getLLMText } from '@/lib/source';
3 -import { notFound } from 'next/navigation';
4 -
5 -export const revalidate = false;
6 -
7 -export async function GET(
8 - _req: Request,
9 - { params }: { params: Promise<{ slug?: string[] }> }
10 -) {
11 - const { slug } = await params;
12 - const page = referenceSource.getPage(slug);
13 - if (!page) notFound();
14 -
15 - return new Response(await getLLMText(page), {
16 - headers: {
17 - 'Content-Type': 'text/markdown; charset=utf-8',
18 - },
19 - });
20 -}
21 -
22 -export function generateStaticParams() {
23 - return referenceSource.generateParams();
24 -}
docs/app/llms.mdx/tool-router/[[...slug]]/route.ts deleted
-24
@@ -1,24 +0,0 @@
1 -import { toolRouterSource } from '@/lib/source';
2 -import { getLLMText } from '@/lib/source';
3 -import { notFound } from 'next/navigation';
4 -
5 -export const revalidate = false;
6 -
7 -export async function GET(
8 - _req: Request,
9 - { params }: { params: Promise<{ slug?: string[] }> }
10 -) {
11 - const { slug } = await params;
12 - const page = toolRouterSource.getPage(slug);
13 - if (!page) notFound();
14 -
15 - return new Response(await getLLMText(page), {
16 - headers: {
17 - 'Content-Type': 'text/markdown; charset=utf-8',
18 - },
19 - });
20 -}
21 -
22 -export function generateStaticParams() {
23 - return toolRouterSource.generateParams();
24 -}
docs/next.config.mjs
+3 -21
@@ -13,27 +13,9 @@ const config = {
13 },
14 async rewrites() {
15 return [
16 - // Support .md and .mdx extensions for AI agents across all sections
17 - // Docs
18 - { source: '/docs/:path*.mdx', destination: '/llms.mdx/docs/:path*' },
19 - { source: '/docs/:path*.md', destination: '/llms.mdx/docs/:path*' },
20 - { source: '/docs.md', destination: '/llms.mdx/docs' },
21 - { source: '/docs.mdx', destination: '/llms.mdx/docs' },
22 - // Tool Router
23 - { source: '/tool-router/:path*.mdx', destination: '/llms.mdx/tool-router/:path*' },
24 - { source: '/tool-router/:path*.md', destination: '/llms.mdx/tool-router/:path*' },
25 - { source: '/tool-router.md', destination: '/llms.mdx/tool-router' },
26 - { source: '/tool-router.mdx', destination: '/llms.mdx/tool-router' },
27 - // Examples
28 - { source: '/examples/:path*.mdx', destination: '/llms.mdx/examples/:path*' },
29 - { source: '/examples/:path*.md', destination: '/llms.mdx/examples/:path*' },
30 - { source: '/examples.md', destination: '/llms.mdx/examples' },
31 - { source: '/examples.mdx', destination: '/llms.mdx/examples' },
32 - // Reference
33 - { source: '/reference/:path*.mdx', destination: '/llms.mdx/reference/:path*' },
34 - { source: '/reference/:path*.md', destination: '/llms.mdx/reference/:path*' },
35 - { source: '/reference.md', destination: '/llms.mdx/reference' },
36 - { source: '/reference.mdx', destination: '/llms.mdx/reference' },
16 + // Serve markdown for AI agents: /any/path.md → /llms.mdx/any/path
17 + { source: '/:path*.md', destination: '/llms.mdx/:path*' },
18 + { source: '/:path*.mdx', destination: '/llms.mdx/:path*' },
19 ];
20 },
21 async redirects() {