Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix: add dynamic toolkit pages to search index
Toolkit pages generated from toolkits.json were not searchable because the search API only indexed Fumadocs MDX pages. Now loads toolkit data via getAllToolkitsSync() and adds entries for each toolkit that doesn't already have an MDX page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 18, 2026 at 17:51 UTC
60f3b52cc331bc2dd7c1a6f32d97cca951d666c4
1 file changed
+28
-10
docs/app/api/search/route.ts
+28
-10
@@ -3,6 +3,7 @@ import { docs, cookbooks, toolkits } from 'fumadocs-mdx:collections/server';
3
import { createSearchAPI } from 'fumadocs-core/search/server';
4
import { loader } from 'fumadocs-core/source';
5
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
6
+import { getAllToolkitsSync } from '@/lib/toolkit-data';
7
8
// Create loaders directly here to avoid the problematic lib/source.ts import
9
const docsSource = loader({
@@ -23,19 +24,36 @@ const toolkitsSource = loader({
24
plugins: [lucideIconsPlugin()],
25
});
26
26
-const allPages = [
27
+// MDX pages from Fumadocs sources
28
+const mdxIndexes = [
29
...docsSource.getPages(),
30
...cookbooksSource.getPages(),
31
...toolkitsSource.getPages(),
30
-];
32
+].map((page) => ({
33
+ id: page.url,
34
+ title: page.data.title ?? 'Untitled',
35
+ description: page.data.description,
36
+ url: page.url,
37
+ structuredData: page.data.structuredData,
38
+ keywords: 'keywords' in page.data ? page.data.keywords : undefined,
39
+}));
40
+
41
+// Dynamic toolkit pages from toolkits.json
42
+const mdxToolkitSlugs = new Set(
43
+ toolkitsSource.getPages().map((page) => page.slugs.join('/')),
44
+);
45
+
46
+const dynamicToolkitIndexes = getAllToolkitsSync()
47
+ .filter((toolkit) => !mdxToolkitSlugs.has(toolkit.slug))
48
+ .map((toolkit) => ({
49
+ id: `/toolkits/${toolkit.slug}`,
50
+ title: toolkit.name,
51
+ description: toolkit.description,
52
+ url: `/toolkits/${toolkit.slug}`,
53
+ structuredData: { headings: [], contents: [] },
54
+ keywords: [toolkit.slug, toolkit.category].filter(Boolean) as string[],
55
+ }));
56
57
export const { GET } = createSearchAPI('advanced', {
33
- indexes: allPages.map((page) => ({
34
- id: page.url,
35
- title: page.data.title ?? 'Untitled',
36
- description: page.data.description,
37
- url: page.url,
38
- structuredData: page.data.structuredData,
39
- keywords: 'keywords' in page.data ? page.data.keywords : undefined,
40
- })),
58
+ indexes: [...mdxIndexes, ...dynamicToolkitIndexes],
59
});