"use server"

import { MDXRemote } from "next-mdx-remote/rsc"
import getCustomComponents from "../../MDXComponents"
import type { ScopeType } from "../../MDXComponents"
import type { MDXRemoteProps } from "next-mdx-remote"

export type MDXContentServerProps = {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  content: any
} & Partial<MDXRemoteProps>

const MDXContentServer = ({ content, ...props }: MDXContentServerProps) => {
  return (
    <>
      <MDXRemote
        source={content}
        components={getCustomComponents((props.scope as ScopeType) || {})}
        options={{
          scope: props.scope,
        }}
        {...props}
      />
    </>
  )
}

export default MDXContentServer
