Skip to content

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

Sushmithamallesh89f09ad8f42d
diff --git a/docs/app/layout.tsx b/docs/app/layout.tsx
index ca25a15e2..f11127ba3 100644
--- a/docs/app/layout.tsx
+++ b/docs/app/layout.tsx
@@ -5,6 +5,22 @@ import './global.css';
import { Inter, IBM_Plex_Mono } from 'next/font/google';
import { PostHogProvider } from '@/components/posthog-provider';
import { DecimalWidget } from '@/components/decimal-widget';
+import CustomSearchDialog from '@/components/custom-search-dialog';
+import { source } from '@/lib/source';
+
+const defaultLinkSlugs = [
+ ['quickstart'],
+ ['authentication'],
+ ['configuring-sessions'],
+ ['common-faq'],
+ ['troubleshooting'],
+];
+
+const defaultLinks = defaultLinkSlugs.flatMap((slug) => {
+ const page = source.getPage(slug);
+ if (!page) return [];
+ return [{ title: page.data.title, description: page.data.description ?? '', href: page.url }];
+});
export const metadata: Metadata = {
title: {
@@ -96,9 +112,10 @@ export default function Layout({ children }: LayoutProps<'/'>) {
enableSystem: true,
}}
search={{
+ SearchDialog: CustomSearchDialog,
options: {
- api: '/api/search',
- },
+ defaultLinks,
+ } as Record<string, unknown>,
}}
>
{children}
diff --git a/docs/components/ask-ai-button.tsx b/docs/components/ask-ai-button.tsx
index b1d8c6e64..053695f2b 100644
--- a/docs/components/ask-ai-button.tsx
+++ b/docs/components/ask-ai-button.tsx
@@ -13,7 +13,7 @@ function getDecimal() {
let widgetOpen = false;
-function toggleDecimalWidget() {
+export function toggleDecimalWidget() {
const decimal = getDecimal();
if (!decimal) {
setTimeout(() => {
diff --git a/docs/components/custom-search-dialog.tsx b/docs/components/custom-search-dialog.tsx
new file mode 100644
index 000000000..8f10edc14
--- /dev/null
+++ b/docs/components/custom-search-dialog.tsx
@@ -0,0 +1,92 @@
+'use client';
+
+import Link from 'next/link';
+import {
+ SearchDialog,
+ SearchDialogClose,
+ SearchDialogContent,
+ SearchDialogHeader,
+ SearchDialogIcon,
+ SearchDialogInput,
+ SearchDialogList,
+ SearchDialogOverlay,
+ type SharedProps,
+} from 'fumadocs-ui/components/dialog/search';
+import { useI18n } from 'fumadocs-ui/contexts/i18n';
+import { useDocsSearch } from 'fumadocs-core/search/client';
+import { BotMessageSquare } from 'lucide-react';
+import { toggleDecimalWidget } from './ask-ai-button';
+
+export interface DefaultLink {
+ title: string;
+ description: string;
+ href: string;
+}
+
+interface CustomSearchDialogProps extends SharedProps {
+ defaultLinks?: DefaultLink[];
+}
+
+export default function CustomSearchDialog({
+ defaultLinks = [],
+ ...props
+}: CustomSearchDialogProps) {
+ const { locale } = useI18n();
+ const { search, setSearch, query } = useDocsSearch({
+ type: 'fetch',
+ locale,
+ api: '/api/search',
+ });
+
+ const isEmpty = query.data === 'empty';
+
+ return (
+ <SearchDialog
+ search={search}
+ onSearchChange={setSearch}
+ isLoading={query.isLoading}
+ {...props}
+ >
+ <SearchDialogOverlay />
+ <SearchDialogContent>
+ <SearchDialogHeader>
+ <SearchDialogIcon />
+ <SearchDialogInput />
+ <SearchDialogClose />
+ </SearchDialogHeader>
+ {isEmpty && defaultLinks.length > 0 ? (
+ <div className="flex flex-col p-2">
+ {defaultLinks.map((link) => (
+ <Link
+ key={link.href}
+ href={link.href}
+ onClick={() => props.onOpenChange(false)}
+ className="rounded-lg px-2.5 py-2 text-start text-sm transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground"
+ >
+ <p className="font-medium">{link.title}</p>
+ <p className="text-xs text-fd-muted-foreground">
+ {link.description}
+ </p>
+ </Link>
+ ))}
+ </div>
+ ) : (
+ <SearchDialogList items={query.data === 'empty' ? null : query.data} />
+ )}
+ <div className="border-t px-3 py-2">
+ <button
+ type="button"
+ className="inline-flex items-center gap-1.5 text-xs text-fd-muted-foreground hover:text-fd-foreground transition-colors"
+ onClick={() => {
+ props.onOpenChange(false);
+ toggleDecimalWidget();
+ }}
+ >
+ <BotMessageSquare className="size-3.5" />
+ You can also Ask AI
+ </button>
+ </div>
+ </SearchDialogContent>
+ </SearchDialog>
+ );
+}