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 { |
| 2 | DocsBody, |
| 3 | DocsPage, |
| 4 | DocsTitle, |
| 5 | } from 'fumadocs-ui/layouts/docs/page'; |
| 6 | import { createRelativeLink } from 'fumadocs-ui/mdx'; |
| 7 | import { notFound, permanentRedirect } from 'next/navigation'; |
| 8 | import { getMDXComponents } from '@/mdx-components'; |
| 9 | import { getPublishedKbGuides } from '@/lib/kb/repository'; |
| 10 | import { PageActions } from '@/components/page-actions'; |
| 11 | import { Feedback } from '@/components/feedback'; |
| 12 | import { |
| 13 | KbGuideVerification, |
| 14 | KbMobileArticleNavigation, |
| 15 | } from '@/components/kb/kb-article-shell'; |
| 16 | import { RelatedLinks } from '@/components/related-links'; |
| 17 | import { knowledgeBaseSource } from '@/lib/source'; |
| 18 | import { createGenerateMetadata } from '@/lib/create-docs-page'; |
| 19 | |
| 20 | interface KnowledgeBaseGuidePageProps { |
| 21 | params: Promise<{ slug: string }>; |
| 22 | } |
| 23 | |
| 24 | export default async function KnowledgeBaseGuidePage({ params }: KnowledgeBaseGuidePageProps) { |
| 25 | const { slug } = await params; |
| 26 | const page = knowledgeBaseSource.getPage(['guide', slug]); |
| 27 | if (!page) { |
| 28 | // Consolidated guides keep their old slugs as aliases; readers and crawlers |
| 29 | // holding an old URL land on the merged page instead of a 404. |
| 30 | const target = getPublishedKbGuides().find((guide) => |
| 31 | guide.aliases.some((alias) => alias.toLowerCase() === slug.toLowerCase()), |
| 32 | ); |
| 33 | if (target) permanentRedirect(`/kb/guide/${target.slug}`); |
| 34 | notFound(); |
| 35 | } |
| 36 | |
| 37 | const MDX = page.data.body; |
| 38 | const lastVerifiedAt = page.data.lastVerifiedAt; |
| 39 | |
| 40 | return ( |
| 41 | <DocsPage |
| 42 | toc={page.data.toc} |
| 43 | full={page.data.full} |
| 44 | footer={{ enabled: false }} |
| 45 | tableOfContentPopover={{ enabled: false }} |
| 46 | tableOfContent={ |
| 47 | page.data.related?.length |
| 48 | ? { footer: <RelatedLinks items={page.data.related} /> } |
| 49 | : undefined |
| 50 | } |
| 51 | > |
| 52 | <KbMobileArticleNavigation /> |
| 53 | <DocsTitle>{page.data.title}</DocsTitle> |
| 54 | <PageActions path={page.url} /> |
| 55 | <DocsBody> |
| 56 | <MDX |
| 57 | components={getMDXComponents({ |
| 58 | a: createRelativeLink(knowledgeBaseSource, page), |
| 59 | })} |
| 60 | /> |
| 61 | {lastVerifiedAt && ( |
| 62 | <div className="not-prose mt-10 flex flex-wrap items-center justify-between gap-4 border-t border-fd-border pt-6"> |
| 63 | <KbGuideVerification lastVerifiedAt={lastVerifiedAt} /> |
| 64 | <Feedback page={page.url} /> |
| 65 | </div> |
| 66 | )} |
| 67 | </DocsBody> |
| 68 | </DocsPage> |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | export function generateStaticParams() { |
| 73 | return knowledgeBaseSource.getPages().flatMap((page) => |
| 74 | page.slugs.length === 2 && page.slugs[0] === 'guide' |
| 75 | ? [{ slug: page.slugs[1] }] |
| 76 | : [], |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | const generateKbMetadata = createGenerateMetadata(knowledgeBaseSource, 'kb'); |
| 81 | |
| 82 | export async function generateMetadata({ params }: KnowledgeBaseGuidePageProps) { |
| 83 | const { slug } = await params; |
| 84 | return generateKbMetadata({ params: Promise.resolve({ slug: ['guide', slug] }) }); |
| 85 | } |