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

next
tsx 57 lines 1.55 KB
Raw
1 'use client';
2
3 import { useMemo, type ReactNode } from 'react';
4 import type { Root } from 'fumadocs-core/page-tree';
5 import { DocsLayout } from 'fumadocs-ui/layouts/docs';
6 import { decorateSidebarBadges } from '@/lib/decorate-sidebar-badges';
7 import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';
8 import type { DocsProduct } from '@/lib/home-navigation';
9 import { SidebarAnalytics } from './sidebar-analytics';
10 import { useDocsProduct } from './docs-product-context';
11
12 interface ProductDocsLayoutProps {
13 children: ReactNode;
14 trees: Record<DocsProduct, Root>;
15 experimentalUrls: string[];
16 newUrls: string[];
17 }
18
19 function ProductDocsLayoutInner({
20 children,
21 trees,
22 experimentalUrls,
23 newUrls,
24 }: ProductDocsLayoutProps) {
25 const { product } = useDocsProduct();
26 const tree = useMemo(
27 () => decorateSidebarBadges(
28 trees[product],
29 new Set(experimentalUrls),
30 new Set(newUrls),
31 ),
32 [experimentalUrls, newUrls, product, trees],
33 );
34 const navIndex = useMemo(() => buildSidebarNavIndex(tree), [tree]);
35
36 return (
37 <DocsLayout
38 containerProps={{ className: 'docs-product-shell' }}
39 nav={{ enabled: true, title: null }}
40 searchToggle={{ enabled: false }}
41 sidebar={{
42 collapsible: false,
43 footer: null,
44 tabs: false,
45 }}
46 themeSwitch={{ enabled: false }}
47 tree={tree}
48 >
49 <SidebarAnalytics index={navIndex} />
50 {children}
51 </DocsLayout>
52 );
53 }
54
55 export function ProductDocsLayout(props: ProductDocsLayoutProps) {
56 return <ProductDocsLayoutInner {...props} />;
57 }