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 | import { RootProvider } from 'fumadocs-ui/provider/next'; |
| 2 | import type { Metadata } from 'next'; |
| 3 | import { headers } from 'next/headers'; |
| 4 | import { Analytics } from '@vercel/analytics/next'; |
| 5 | import './global.css'; |
| 6 | import { JetBrains_Mono } from 'next/font/google'; |
| 7 | import localFont from 'next/font/local'; |
| 8 | import { PostHogProvider } from '@/components/posthog-provider'; |
| 9 | import CustomSearchDialog from '@/components/custom-search-dialog'; |
| 10 | import { ScrollReset } from '@/components/scroll-reset'; |
| 11 | import { source, referenceSource, getOgImageUrl } from '@/lib/source'; |
| 12 | import { TOOLKIT_COUNT_LABEL, HOME_OG_DESCRIPTION } from '@/lib/toolkit-count'; |
| 13 | import { ProductTransitionLoader } from '@/components/product-transition-loader'; |
| 14 | import { DocsProductProvider } from '@/components/docs-product-context'; |
| 15 | import { |
| 16 | DEFAULT_DOCS_PRODUCT, |
| 17 | DOCS_PRODUCTS, |
| 18 | DOCS_PRODUCT_HEADER, |
| 19 | parseDocsProduct, |
| 20 | } from '@/lib/home-navigation'; |
| 21 | |
| 22 | const defaultLinkSlugs: { slug: string[]; source: typeof source }[] = [ |
| 23 | { slug: ['quickstart'], source }, |
| 24 | { slug: ['authentication'], source }, |
| 25 | { slug: ['configuring-sessions'], source }, |
| 26 | { slug: ['authentication', 'white-labeling-authentication'], source }, |
| 27 | { slug: ['glossary'], source: referenceSource }, |
| 28 | { slug: ['troubleshooting'], source }, |
| 29 | ]; |
| 30 | |
| 31 | const defaultLinks = defaultLinkSlugs.flatMap(({ slug, source: pageSource }) => { |
| 32 | const page = pageSource.getPage(slug); |
| 33 | if (!page) return []; |
| 34 | return [{ title: page.data.title, description: page.data.description ?? '', href: page.url }]; |
| 35 | }); |
| 36 | |
| 37 | const SITE_DESCRIPTION = `Build AI agents with ${TOOLKIT_COUNT_LABEL} apps. Connect LLMs to external services like GitHub, Slack, Gmail, and more.`; |
| 38 | const HOME_OG_IMAGE = getOgImageUrl('docs', [], 'Composio Docs', HOME_OG_DESCRIPTION); |
| 39 | |
| 40 | export const metadata: Metadata = { |
| 41 | title: { |
| 42 | default: 'Composio Docs', |
| 43 | template: '%s | Composio', |
| 44 | }, |
| 45 | description: SITE_DESCRIPTION, |
| 46 | metadataBase: new URL('https://docs.composio.dev'), |
| 47 | openGraph: { |
| 48 | title: 'Composio Docs', |
| 49 | description: SITE_DESCRIPTION, |
| 50 | siteName: 'Composio Docs', |
| 51 | type: 'website', |
| 52 | images: [HOME_OG_IMAGE], |
| 53 | }, |
| 54 | twitter: { |
| 55 | card: 'summary_large_image', |
| 56 | title: 'Composio Docs', |
| 57 | description: SITE_DESCRIPTION, |
| 58 | images: [HOME_OG_IMAGE], |
| 59 | }, |
| 60 | }; |
| 61 | |
| 62 | const abcDiatype = localFont({ |
| 63 | src: [ |
| 64 | { path: '../public/fonts/ABCDiatype-Regular.woff2', weight: '400', style: 'normal' }, |
| 65 | { path: '../public/fonts/ABCDiatype-RegularItalic.woff2', weight: '400', style: 'italic' }, |
| 66 | { path: '../public/fonts/ABCDiatype-Medium.woff2', weight: '500', style: 'normal' }, |
| 67 | ], |
| 68 | variable: '--font-sans', |
| 69 | display: 'swap', |
| 70 | }); |
| 71 | |
| 72 | const jetbrainsMono = JetBrains_Mono({ |
| 73 | subsets: ['latin'], |
| 74 | variable: '--font-mono', |
| 75 | display: 'swap', |
| 76 | }); |
| 77 | |
| 78 | export default async function Layout({ children }: LayoutProps<'/'>) { |
| 79 | const initialProduct = |
| 80 | parseDocsProduct((await headers()).get(DOCS_PRODUCT_HEADER)) ?? DEFAULT_DOCS_PRODUCT; |
| 81 | const initialTheme = DOCS_PRODUCTS[initialProduct].theme; |
| 82 | |
| 83 | return ( |
| 84 | <html |
| 85 | lang="en" |
| 86 | className={`${abcDiatype.variable} ${jetbrainsMono.variable}`} |
| 87 | suppressHydrationWarning |
| 88 | > |
| 89 | <head> |
| 90 | <script |
| 91 | dangerouslySetInnerHTML={{ |
| 92 | __html: `try{document.documentElement.classList.remove('light','dark');document.documentElement.classList.add('${initialTheme}');document.documentElement.style.colorScheme='${initialTheme}'}catch{}`, |
| 93 | }} |
| 94 | /> |
| 95 | <meta name="theme-color" content={DOCS_PRODUCTS[initialProduct].themeColor} /> |
| 96 | <script |
| 97 | type="application/ld+json" |
| 98 | dangerouslySetInnerHTML={{ |
| 99 | __html: JSON.stringify({ |
| 100 | '@context': 'https://schema.org', |
| 101 | '@graph': [ |
| 102 | { |
| 103 | '@type': 'WebSite', |
| 104 | '@id': 'https://docs.composio.dev/#website', |
| 105 | url: 'https://docs.composio.dev', |
| 106 | name: 'Composio Docs', |
| 107 | description: SITE_DESCRIPTION, |
| 108 | publisher: { '@id': 'https://composio.dev/#organization' }, |
| 109 | }, |
| 110 | { |
| 111 | '@type': 'Organization', |
| 112 | '@id': 'https://composio.dev/#organization', |
| 113 | name: 'Composio', |
| 114 | url: 'https://composio.dev', |
| 115 | logo: { |
| 116 | '@type': 'ImageObject', |
| 117 | url: 'https://composio.dev/logo.png', |
| 118 | }, |
| 119 | sameAs: [ |
| 120 | 'https://github.com/composiohq', |
| 121 | 'https://x.com/composiodevs', |
| 122 | 'https://discord.gg/composio', |
| 123 | ], |
| 124 | }, |
| 125 | ], |
| 126 | }), |
| 127 | }} |
| 128 | /> |
| 129 | </head> |
| 130 | <body className="flex flex-col min-h-dvh font-sans"> |
| 131 | <ScrollReset /> |
| 132 | <ProductTransitionLoader /> |
| 133 | <Analytics /> |
| 134 | <PostHogProvider> |
| 135 | {/* DocsProductProvider owns the rendered theme; useTheme().resolvedTheme is not a product-theme signal. */} |
| 136 | <RootProvider |
| 137 | theme={{ |
| 138 | defaultTheme: 'system', |
| 139 | forcedTheme: initialTheme, |
| 140 | storageKey: 'composio-docs-theme', |
| 141 | attribute: 'class', |
| 142 | enableSystem: true, |
| 143 | hotKey: false, |
| 144 | }} |
| 145 | search={{ |
| 146 | SearchDialog: CustomSearchDialog, |
| 147 | options: { |
| 148 | api: '/api/search', |
| 149 | defaultLinks, |
| 150 | } as Record<string, unknown>, |
| 151 | }} |
| 152 | > |
| 153 | <DocsProductProvider initialProduct={initialProduct}>{children}</DocsProductProvider> |
| 154 | </RootProvider> |
| 155 | </PostHogProvider> |
| 156 | </body> |
| 157 | </html> |
| 158 | ); |
| 159 | } |