import defaultMdxComponents from 'fumadocs-ui/mdx'
import type { MDXComponents } from 'mdx/types'
import NextImage, { type ImageProps } from 'next/image'
import { ReactNode } from 'react'
const IMAGE_BASE_URL = ''
const genericComponents = {
Image: (
props: ImageProps & {
srcLight?: string
srcDark?: string
alt?: string
caption?: string
src?: string
}
) => {
const {
src,
srcLight,
srcDark,
caption,
alt = caption || '',
...rest
} = props
const hasThemeVariants = srcLight && srcDark
const sharedClasses = 'rounded-md border border-gray-200 bg-gray-100'
return (
{/* Image variants (srcLight and srcDark) provided */}
{hasThemeVariants ? (
<>
>
) : (
/* Only src provided - show in both themes */
)}
{caption ? {caption} : null}
)
},
Check: ({ size }: { size: number }) => (
✓
),
Cross: ({ size }: { size: number }): ReactNode => (
❌
),
}
// use this function to get MDX components, you will need it for rendering MDX
export function getMDXComponents(
components?: MDXComponents,
opts?: { isApp?: boolean; isPages?: boolean }
): MDXComponents {
const isApp = opts?.isApp
const isPages = opts?.isPages
return {
...defaultMdxComponents,
...genericComponents,
AppOnly: ({ children }: { children: ReactNode }): ReactNode =>
isApp ? children : null,
PagesOnly: ({ children }: { children: ReactNode }): ReactNode =>
isPages ? children : null,
...components,
}
}