Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 06:00 UTC
| 1 | import { markdownAlternates } from '@/lib/markdown-alternates'; |
| 2 | import type { Metadata } from 'next'; |
| 3 | import Link from 'next/link'; |
| 4 | import { notFound, redirect } from 'next/navigation'; |
| 5 | import { ArrowLeft, Wrench } from 'lucide-react'; |
| 6 | import { BrowseResults } from '@/components/kb/browse-results'; |
| 7 | import { |
| 8 | getKnowledgeByToolkit, |
| 9 | getKnowledgeToolkitSummaries, |
| 10 | } from '@/lib/knowledge/catalog'; |
| 11 | import { getToolkitKnowledgeRedirect } from '@/lib/knowledge/toolkit-routing'; |
| 12 | |
| 13 | interface ToolkitPageProps { |
| 14 | params: Promise<{ slug: string }>; |
| 15 | } |
| 16 | |
| 17 | async function getToolkitSummary(slug: string) { |
| 18 | const summaries = await getKnowledgeToolkitSummaries(); |
| 19 | return summaries.find((candidate) => candidate.slug === slug) ?? null; |
| 20 | } |
| 21 | |
| 22 | export default async function KnowledgeToolkitPage({ params }: ToolkitPageProps) { |
| 23 | const { slug } = await params; |
| 24 | const toolkit = await getToolkitSummary(slug); |
| 25 | if (!toolkit) notFound(); |
| 26 | const toolkitRedirect = getToolkitKnowledgeRedirect(toolkit); |
| 27 | if (toolkitRedirect) redirect(toolkitRedirect); |
| 28 | const links = await getKnowledgeByToolkit(slug); |
| 29 | |
| 30 | return ( |
| 31 | <main className="mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 sm:py-14 lg:px-8"> |
| 32 | <Link href="/kb/toolkits" className="inline-flex items-center gap-2 text-sm text-fd-muted-foreground hover:text-fd-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring"> |
| 33 | <ArrowLeft className="size-4" aria-hidden="true" /> Browse toolkits |
| 34 | </Link> |
| 35 | <div className="mt-8 flex max-w-3xl items-start gap-5"> |
| 36 | <span className="flex size-14 shrink-0 items-center justify-center border border-fd-border bg-fd-background"> |
| 37 | {toolkit.logo |
| 38 | ? <img src={toolkit.logo} alt="" className="size-9 object-contain" /> |
| 39 | : <Wrench className="size-6 text-fd-muted-foreground" aria-hidden="true" />} |
| 40 | </span> |
| 41 | <div> |
| 42 | <p className="text-sm font-medium text-fd-primary">Toolkit knowledge</p> |
| 43 | <h1 className="mt-1 text-3xl font-semibold tracking-tight sm:text-4xl">{toolkit.name}</h1> |
| 44 | </div> |
| 45 | </div> |
| 46 | <div className="mt-10"> |
| 47 | <BrowseResults links={links} variant="toolkit" toolkitName={toolkit.name} /> |
| 48 | </div> |
| 49 | </main> |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | export async function generateMetadata({ params }: ToolkitPageProps): Promise<Metadata> { |
| 54 | const { slug } = await params; |
| 55 | const toolkit = await getToolkitSummary(slug); |
| 56 | if (!toolkit) return { title: 'Toolkit knowledge not found' }; |
| 57 | return { |
| 58 | title: `${toolkit.name} knowledge`, |
| 59 | description: `Find public Composio docs, support answers, OAuth guides, examples, and reference pages for ${toolkit.name}.`, |
| 60 | alternates: markdownAlternates(`/kb/toolkit/${toolkit.slug}`), |
| 61 | }; |
| 62 | } |