import * as React from "react" import { registryItemSchema } from "shadcn/schema" import { z } from "zod" import { highlightCode } from "@/lib/highlight-code" import { getRegistryItem } from "@/lib/registry" import { cn } from "@/lib/utils" import { ChartToolbar } from "@/components/chart-toolbar" export type Chart = z.infer & { highlightedCode: string } export async function ChartDisplay({ name, children, className, }: { name: string } & React.ComponentProps<"div">) { const chart = await getCachedRegistryItem(name) const highlightedCode = await getChartHighlightedCode( chart?.files?.[0]?.content ?? "" ) if (!chart || !highlightedCode) { return null } return (
{children}
{children}
) } const getCachedRegistryItem = React.cache(async (name: string) => { return await getRegistryItem(name) }) const getChartHighlightedCode = React.cache(async (content: string) => { return await highlightCode(content) })