import Image from "next/image"; import { ComponentProps, DetailedHTMLProps, HTMLAttributes } from "react"; import dynamic from "next/dynamic"; // Dynamically import the Mermaid component const Mermaid = dynamic(() => import("@/components/blog/Mermaid"), { ssr: false, }); export type MDXComponents = { p: ( props: DetailedHTMLProps< HTMLAttributes, HTMLParagraphElement > ) => JSX.Element; img: (props: ComponentProps<"img">) => JSX.Element; pre: ( props: DetailedHTMLProps, HTMLPreElement> ) => JSX.Element; code: ( props: DetailedHTMLProps, HTMLElement> ) => JSX.Element; table: ( props: DetailedHTMLProps, HTMLTableElement> ) => JSX.Element; thead: ( props: DetailedHTMLProps< HTMLAttributes, HTMLTableSectionElement > ) => JSX.Element; tbody: ( props: DetailedHTMLProps< HTMLAttributes, HTMLTableSectionElement > ) => JSX.Element; tr: ( props: DetailedHTMLProps< HTMLAttributes, HTMLTableRowElement > ) => JSX.Element; th: ( props: DetailedHTMLProps< HTMLAttributes, HTMLTableCellElement > ) => JSX.Element; td: ( props: DetailedHTMLProps< HTMLAttributes, HTMLTableCellElement > ) => JSX.Element; blockquote: ( props: DetailedHTMLProps, HTMLQuoteElement> ) => JSX.Element; ul: ( props: DetailedHTMLProps, HTMLUListElement> ) => JSX.Element; ol: ( props: DetailedHTMLProps, HTMLOListElement> ) => JSX.Element; li: ( props: DetailedHTMLProps, HTMLLIElement> ) => JSX.Element; mermaid: React.ComponentType<{ children: string }>; }; // Custom MDX components export const mdxComponents: MDXComponents = { p: ({ children, ...props }) => (
{children}
), img: (props) => { const { src, ...rest } = props; if (!src) { return
Image source is missing
; } return (
{props.alt {props.alt && (
{props.alt}
)}
); }, pre: ({ children, ...props }) => (
      {children}
    
), code: ({ children, className, ...props }) => { const isInlineCode = !className; return isInlineCode ? ( {children} ) : ( {children} ); }, table: ({ children, ...props }) => (
{children}
), thead: ({ children, ...props }) => ( {children} ), tbody: ({ children, ...props }) => ( {children} ), tr: ({ children, ...props }) => ( {children} ), th: ({ children, ...props }) => ( {children} ), td: ({ children, ...props }) => ( {children} ), blockquote: ({ children, ...props }) => (
{children}
), ul: ({ children, ...props }) => (
    {children}
), ol: ({ children, ...props }) => (
    {children}
), li: ({ children, ...props }) => (
  • {children}
  • ), mermaid: Mermaid, // Use the defined Mermaid component };