"use client"; import type { JSX } from "react"; import { bundledLanguages, codeToHast, type BundledLanguage, } from "shiki/bundle/web"; import { Fragment, useLayoutEffect, useState } from "react"; import { jsx, jsxs } from "react/jsx-runtime"; import { toJsxRuntime } from "hast-util-to-jsx-runtime"; import { safe } from "ts-safe"; import { cn } from "lib/utils"; import { useTheme } from "next-themes"; import { Button } from "ui/button"; import { CheckIcon, CopyIcon } from "lucide-react"; import JsonView from "ui/json-view"; import { useCopy } from "@/hooks/use-copy"; import dynamic from "next/dynamic"; // Dynamically import MermaidDiagram component const MermaidDiagram = dynamic( () => import("./mermaid-diagram").then((mod) => mod.MermaidDiagram), { loading: () => (
{lang}
{children}
);
};
export async function Highlight(
code: string,
lang: BundledLanguage | (string & {}),
theme: string,
) {
const parsed: BundledLanguage = (
bundledLanguages[lang] ? lang : "md"
) as BundledLanguage;
if (lang === "json") {
return (