Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: add default links and Ask AI to search dialog
Custom search dialog shows quick-access links (Quickstart, Authentication, Configuring Sessions, General FAQs, Troubleshooting) with subtitles when search is empty. Titles and descriptions are derived from MDX page frontmatter at build time. Adds "Ask AI" button inside dialog content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 19, 2026 at 22:44 UTC
89f09ad8f42d522bfbdbda67c66b8d769a3d6ba4
3 files changed
+112
-3
docs/app/layout.tsx
+19
-2
@@ -5,6 +5,22 @@ import './global.css';
5
import { Inter, IBM_Plex_Mono } from 'next/font/google';
6
import { PostHogProvider } from '@/components/posthog-provider';
7
import { DecimalWidget } from '@/components/decimal-widget';
8
+import CustomSearchDialog from '@/components/custom-search-dialog';
9
+import { source } from '@/lib/source';
10
+
11
+const defaultLinkSlugs = [
12
+ ['quickstart'],
13
+ ['authentication'],
14
+ ['configuring-sessions'],
15
+ ['common-faq'],
16
+ ['troubleshooting'],
17
+];
18
+
19
+const defaultLinks = defaultLinkSlugs.flatMap((slug) => {
20
+ const page = source.getPage(slug);
21
+ if (!page) return [];
22
+ return [{ title: page.data.title, description: page.data.description ?? '', href: page.url }];
23
+});
24
25
export const metadata: Metadata = {
26
title: {
@@ -96,9 +112,10 @@ export default function Layout({ children }: LayoutProps<'/'>) {
112
enableSystem: true,
113
}}
114
search={{
115
+ SearchDialog: CustomSearchDialog,
116
options: {
100
- api: '/api/search',
101
- },
117
+ defaultLinks,
118
+ } as Record<string, unknown>,
119
}}
120
>
121
{children}
docs/components/ask-ai-button.tsx
+1
-1
@@ -13,7 +13,7 @@ function getDecimal() {
13
14
let widgetOpen = false;
15
16
-function toggleDecimalWidget() {
16
+export function toggleDecimalWidget() {
17
const decimal = getDecimal();
18
if (!decimal) {
19
setTimeout(() => {
docs/components/custom-search-dialog.tsx
new
+92
@@ -0,0 +1,92 @@
1
+'use client';
2
+
3
+import Link from 'next/link';
4
+import {
5
+ SearchDialog,
6
+ SearchDialogClose,
7
+ SearchDialogContent,
8
+ SearchDialogHeader,
9
+ SearchDialogIcon,
10
+ SearchDialogInput,
11
+ SearchDialogList,
12
+ SearchDialogOverlay,
13
+ type SharedProps,
14
+} from 'fumadocs-ui/components/dialog/search';
15
+import { useI18n } from 'fumadocs-ui/contexts/i18n';
16
+import { useDocsSearch } from 'fumadocs-core/search/client';
17
+import { BotMessageSquare } from 'lucide-react';
18
+import { toggleDecimalWidget } from './ask-ai-button';
19
+
20
+export interface DefaultLink {
21
+ title: string;
22
+ description: string;
23
+ href: string;
24
+}
25
+
26
+interface CustomSearchDialogProps extends SharedProps {
27
+ defaultLinks?: DefaultLink[];
28
+}
29
+
30
+export default function CustomSearchDialog({
31
+ defaultLinks = [],
32
+ ...props
33
+}: CustomSearchDialogProps) {
34
+ const { locale } = useI18n();
35
+ const { search, setSearch, query } = useDocsSearch({
36
+ type: 'fetch',
37
+ locale,
38
+ api: '/api/search',
39
+ });
40
+
41
+ const isEmpty = query.data === 'empty';
42
+
43
+ return (
44
+ <SearchDialog
45
+ search={search}
46
+ onSearchChange={setSearch}
47
+ isLoading={query.isLoading}
48
+ {...props}
49
+ >
50
+ <SearchDialogOverlay />
51
+ <SearchDialogContent>
52
+ <SearchDialogHeader>
53
+ <SearchDialogIcon />
54
+ <SearchDialogInput />
55
+ <SearchDialogClose />
56
+ </SearchDialogHeader>
57
+ {isEmpty && defaultLinks.length > 0 ? (
58
+ <div className="flex flex-col p-2">
59
+ {defaultLinks.map((link) => (
60
+ <Link
61
+ key={link.href}
62
+ href={link.href}
63
+ onClick={() => props.onOpenChange(false)}
64
+ className="rounded-lg px-2.5 py-2 text-start text-sm transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground"
65
+ >
66
+ <p className="font-medium">{link.title}</p>
67
+ <p className="text-xs text-fd-muted-foreground">
68
+ {link.description}
69
+ </p>
70
+ </Link>
71
+ ))}
72
+ </div>
73
+ ) : (
74
+ <SearchDialogList items={query.data === 'empty' ? null : query.data} />
75
+ )}
76
+ <div className="border-t px-3 py-2">
77
+ <button
78
+ type="button"
79
+ className="inline-flex items-center gap-1.5 text-xs text-fd-muted-foreground hover:text-fd-foreground transition-colors"
80
+ onClick={() => {
81
+ props.onOpenChange(false);
82
+ toggleDecimalWidget();
83
+ }}
84
+ >
85
+ <BotMessageSquare className="size-3.5" />
86
+ You can also Ask AI
87
+ </button>
88
+ </div>
89
+ </SearchDialogContent>
90
+ </SearchDialog>
91
+ );
92
+}