import { useState, useEffect } from "react"; import { highlightCode } from "@/lib/shiki"; interface UseHighlightedCodeResult { html: string | null; loading: boolean; error: Error | null; } /** * Hook to highlight code asynchronously with lazy language loading * * @example * const { html, loading } = useHighlightedCode(code, "typescript") * if (loading) return
{code}
* return
*/
export function useHighlightedCode(
code: string,
language: string | null | undefined,
): UseHighlightedCodeResult {
const [html, setHtml] = useState