@devries-cameron20 / composio Mirror · read-only / commits / 4857f5c44
Fork 0

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 22, 09:30 UTC

refactor: extract slugify to shared utility

Move duplicated slugify logic from mdx-components.tsx and faq-section.tsx into lib/utils.ts. Also fix import ordering in mdx-components.tsx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmithamallesh committed Feb 11, 2026 at 20:19 UTC 4857f5c44c692eb9b44fd1c3d01502f08a11bae3
3 files changed +12 -10
docs/components/toolkits/faq-section.tsx
+2 -1
@@ -2,6 +2,7 @@
2
3 import { HelpCircle } from 'lucide-react';
4 import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
5 +import { slugify } from '@/lib/utils';
6
7 export interface FaqItem {
8 question: string;
@@ -23,7 +24,7 @@ export function FaqSection({ faq }: FaqSectionProps) {
24 </h2>
25 <Accordions type="single">
26 {faq.map((item) => (
26 - <Accordion key={item.question} title={item.question} id={item.question.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '')}>
27 + <Accordion key={item.question} title={item.question} id={slugify(item.question)}>
28 <div
29 className="prose prose-sm prose-fd max-w-none text-fd-muted-foreground"
30 dangerouslySetInnerHTML={{ __html: item.answer }}
docs/lib/utils.ts
+4
@@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge"
4 export function cn(...inputs: ClassValue[]) {
5 return twMerge(clsx(inputs))
6 }
7 +
8 +export function slugify(text: string): string {
9 + return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '');
10 +}
docs/mdx-components.tsx
+6 -9
@@ -1,18 +1,10 @@
1 import defaultMdxComponents from 'fumadocs-ui/mdx';
2 import type { MDXComponents } from 'mdx/types';
3 +import type { ComponentProps } from 'react';
4 import { Heading } from '@/components/heading';
5 import { YouTube } from '@/components/youtube';
6 import { Tabs, Tab, TabsList, TabsTrigger, TabsContent } from 'fumadocs-ui/components/tabs';
7 import { Accordion as BaseAccordion, Accordions } from 'fumadocs-ui/components/accordion';
7 -import type { ComponentProps } from 'react';
8 -
9 -function slugify(text: string): string {
10 - return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '');
11 -}
12 -
13 -function Accordion({ id, title, ...props }: ComponentProps<typeof BaseAccordion>) {
14 - return <BaseAccordion id={id ?? (typeof title === 'string' ? slugify(title) : undefined)} title={title} {...props} />;
15 -}
8 import { Callout } from 'fumadocs-ui/components/callout';
9 import { Step, Steps } from 'fumadocs-ui/components/steps';
10 import { Card, Cards } from 'fumadocs-ui/components/card';
@@ -27,6 +19,7 @@ import { Video } from '@/components/video';
19 import { CapabilityCard, CapabilityList } from '@/components/capability-card';
20 import { ToolkitsLanding } from '@/components/toolkits/toolkits-landing';
21 import { Mermaid } from '@/components/mermaid';
22 +import { slugify } from '@/lib/utils';
23 import { ShieldCheck, Route as RouteIcon } from 'lucide-react';
24 import {
25 Key,
@@ -43,6 +36,10 @@ import {
36 BookOpen,
37 } from 'lucide-react';
38
39 +function Accordion({ id, title, ...props }: ComponentProps<typeof BaseAccordion>) {
40 + return <BaseAccordion id={id ?? (typeof title === 'string' ? slugify(title) : undefined)} title={title} {...props} />;
41 +}
42 +
43 export function getMDXComponents(components?: MDXComponents): MDXComponents {
44 return {
45 ...defaultMdxComponents,