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.

1.4 KB
Raw Blame
import { getReferenceSource } from '@/lib/source';
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
import type { ReactNode } from 'react';
import { prepareTree } from '@/lib/filter-api-version';
import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';
import { SidebarAnalytics } from '@/components/sidebar-analytics';

export default async function Layout({ children }: { children: ReactNode }) {
  const source = await getReferenceSource();
  const tree = prepareTree(source.pageTree, '3.1');
  const changelogPage = { type: 'page' as const, name: 'Changelog', url: '/reference/changelog' };
  // Pin Changelog directly beneath Overview (the first/top entry) in the sidebar.
  const overviewIdx = tree.children.findIndex(
    child => child.type === 'page' && child.name === 'Overview'
  );
  const insertIdx = overviewIdx === -1 ? Math.min(1, tree.children.length) : overviewIdx + 1;
  const pageTree = {
    ...tree,
    children: [
      ...tree.children.slice(0, insertIdx),
      changelogPage,
      ...tree.children.slice(insertIdx),
    ] as typeof tree.children,
  };
  const navIndex = buildSidebarNavIndex(pageTree);

  return (
    <DocsLayout
      tree={pageTree}
      nav={{ enabled: true, title: null }}
      searchToggle={{ enabled: false }}
      sidebar={{ collapsible: false, footer: null, tabs: false }}
      themeSwitch={{ enabled: false }}
    >
      <SidebarAnalytics index={navIndex} />
      {children}
    </DocsLayout>
  );
}