{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "server-codeblock",
  "title": "Server code block",
  "description": "ServerCodeBlock: a code block highlighted with Shiki in a React Server Component.",
  "dependencies": [
    "cn",
    "fumadocs-core@^16.17.8"
  ],
  "registryDependencies": [
    "@docscn/codeblock"
  ],
  "files": [
    {
      "path": "registry/base/docs/components/codeblock.rsc.tsx",
      "content": "// Adapted from Fumadocs UI (https://github.com/fuma-nama/fumadocs)\n// Copyright (c) 2023 Fuma, MIT License\nimport type { ComponentProps } from \"react\";\nimport { toJsx } from \"fumadocs-core/utils/hast-to-jsx\";\nimport { CodeBlock, type CodeBlockProps, Pre } from \"./codeblock\";\nimport {\n  highlight,\n  type Highlighter,\n  type HighlightOptions,\n} from \"fumadocs-core/highlight\";\nimport { cn } from \"cn\";\n\nexport type ServerCodeBlockProps = HighlightOptions & {\n  code: string;\n\n  /**\n   * Extra props for the underlying `<CodeBlock />` component.\n   *\n   * Ignored if you defined your own `pre` component in `components`.\n   */\n  codeblock?: CodeBlockProps;\n};\n\nexport async function ServerCodeBlock({\n  code,\n  codeblock,\n  ...options\n}: ServerCodeBlockProps) {\n  return await highlight(code, {\n    defaultColor: false,\n    ...options,\n    components: {\n      pre: createPre(codeblock),\n      ...options.components,\n    },\n  });\n}\n\n/**\n * Create a server code block that highlights with your own highlighter.\n */\nexport function createServerCodeBlock({\n  highlighter,\n}: {\n  highlighter: Highlighter;\n}) {\n  return async function ServerCodeBlock({\n    code,\n    lang,\n    codeblock,\n  }: Pick<ServerCodeBlockProps, \"code\" | \"lang\" | \"codeblock\">) {\n    await highlighter.loadLanguage?.(lang);\n\n    return toJsx(highlighter.codeToHast(code, { lang }), {\n      components: { pre: createPre(codeblock) },\n    });\n  };\n}\n\nfunction createPre(codeblock?: CodeBlockProps) {\n  return function ServerPre(props: ComponentProps<\"pre\">) {\n    return (\n      <CodeBlock\n        {...props}\n        {...codeblock}\n        className={cn(\"my-0\", props.className, codeblock?.className)}\n      >\n        <Pre>{props.children}</Pre>\n      </CodeBlock>\n    );\n  };\n}\n",
      "type": "registry:component",
      "target": "@components/docs/components/codeblock.rsc.tsx"
    }
  ],
  "type": "registry:component"
}