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, permanentRedirect } from 'next/navigation'; |
| 5 | import { ArrowLeft } from 'lucide-react'; |
| 6 | import { BrowseResults } from '@/components/kb/browse-results'; |
| 7 | import { getKnowledgeByProductArea } from '@/lib/knowledge/catalog'; |
| 8 | import { |
| 9 | getProductArea, |
| 10 | getProductAreaRedirect, |
| 11 | isProductAreaSlug, |
| 12 | PRODUCT_AREAS, |
| 13 | } from '@/lib/knowledge/taxonomy'; |
| 14 | |
| 15 | interface TopicPageProps { |
| 16 | params: Promise<{ slug: string }>; |
| 17 | } |
| 18 | |
| 19 | export default async function KnowledgeTopicPage({ params }: TopicPageProps) { |
| 20 | const { slug } = await params; |
| 21 | const redirect = getProductAreaRedirect(slug); |
| 22 | if (redirect) permanentRedirect(redirect); |
| 23 | if (!isProductAreaSlug(slug)) notFound(); |
| 24 | const area = getProductArea(slug); |
| 25 | const links = await getKnowledgeByProductArea(slug); |
| 26 | if (!area.defaultBrowse && links.length === 0) notFound(); |
| 27 | |
| 28 | return ( |
| 29 | <main className="mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 sm:py-14 lg:px-8"> |
| 30 | <nav aria-label="Knowledge Base topic navigation"> |
| 31 | <Link |
| 32 | href="/kb" |
| 33 | className="mb-8 inline-flex items-center gap-2 text-sm text-fd-muted-foreground transition-colors hover:text-fd-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring" |
| 34 | > |
| 35 | <ArrowLeft className="size-4" aria-hidden="true" /> |
| 36 | Knowledge Base |
| 37 | </Link> |
| 38 | </nav> |
| 39 | <div className="max-w-3xl"> |
| 40 | <h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">{area.title}</h1> |
| 41 | <p className="mt-4 text-base leading-7 text-fd-muted-foreground">{area.description}</p> |
| 42 | </div> |
| 43 | <div className="mt-10"><BrowseResults links={links} variant="topic" /></div> |
| 44 | </main> |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | export function generateStaticParams() { |
| 49 | return PRODUCT_AREAS.filter((area) => area.defaultBrowse).map((area) => ({ slug: area.slug })); |
| 50 | } |
| 51 | |
| 52 | export async function generateMetadata({ params }: TopicPageProps): Promise<Metadata> { |
| 53 | const { slug } = await params; |
| 54 | if (!isProductAreaSlug(slug)) return { title: 'Knowledge topic not found' }; |
| 55 | const area = getProductArea(slug); |
| 56 | return { |
| 57 | title: `${area.title} knowledge`, |
| 58 | description: area.description, |
| 59 | alternates: markdownAlternates(`/kb/topic/${area.slug}`), |
| 60 | }; |
| 61 | } |