/** * MDX components provider for the Nextra compatibility layer. * This module is used as the `providerImportSource` for @mdx-js/loader * to automatically provide components that Nextra used to inject * via theme.config.tsx's `components` property. */ import type { ReactNode, ComponentType } from 'react' interface ChildrenProps { children?: ReactNode [key: string]: any } function Callout({ children, type = 'info', ...props }: ChildrenProps & { type?: string }) { return (
{children}
) } function Steps({ children }: ChildrenProps) { return
{children}
} function Tab({ children }: ChildrenProps) { return
{children}
} function TabsComponent({ children }: ChildrenProps) { return
{children}
} /** Nextra's Tabs component uses compound pattern: `` */ const Tabs = Object.assign(TabsComponent, { Tab }) function Card({ children, title, href, ...props }: ChildrenProps & { title?: string; href?: string }) { const content = (
{title &&

{title}

} {children}
) if (href) return {content} return content } function CardsComponent({ children }: ChildrenProps) { return
{children}
} /** Nextra's Cards component uses compound pattern: `` */ const Cards = Object.assign(CardsComponent, { Card }) function FileComponent({ children, name, ...props }: ChildrenProps & { name?: string }) { return (
{name && {name}} {children}
) } function FolderComponent({ children, name, ...props }: ChildrenProps & { name?: string }) { return (
{name && {name}/} {children}
) } function FileTreeBase({ children }: ChildrenProps) { return
{children}
} /** Nextra's FileTree uses compound pattern: ``, `` */ const FileTree = Object.assign(FileTreeBase, { File: FileComponent, Folder: FolderComponent, }) function OptionTable({ options, ...props }: { options: any[]; [key: string]: any }) { if (!options || !Array.isArray(options)) return null return ( {options.map((opt: any, i: number) => ( ))}
Option Type Description
{opt[0]} {opt[1]} {opt[2]}
) } function Button({ children, ...props }: ChildrenProps) { return } function Carousel({ children }: ChildrenProps) { return
{children}
} function Frame({ children }: ChildrenProps) { return
{children}
} const components: Record> = { Callout, Steps, Tabs, Tab, Cards, Card, FileTree, OptionTable, Button, Carousel, Frame, } export function useMDXComponents(existing: Record> = {}) { return { ...components, ...existing } } export function MDXProvider({ children }: { children: ReactNode }) { return <>{children} }