From 7b394b91e2b40d526b36b3d468445ed1726bb297 Mon Sep 17 00:00:00 2001
From: Jay V <air@live.ca>
Date: Fri, 27 Jun 2025 20:21:28 -0400
Subject: docs: share handle slower code blocks

---
 packages/web/src/components/CodeBlock.tsx | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

(limited to 'packages/web/src/components/CodeBlock.tsx')

diff --git a/packages/web/src/components/CodeBlock.tsx b/packages/web/src/components/CodeBlock.tsx
index 03744550e..4c6aab48e 100644
--- a/packages/web/src/components/CodeBlock.tsx
+++ b/packages/web/src/components/CodeBlock.tsx
@@ -18,16 +18,19 @@ function CodeBlock(props: CodeBlockProps) {
   const [local, rest] = splitProps(props, ["code", "lang", "onRendered"])
   let containerRef!: HTMLDivElement
 
-  const [html] = createResource(() => [local.code, local.lang], async ([code, lang]) => {
-    return (await codeToHtml(code || "", {
-      lang: lang || "text",
-      themes: {
-        light: "github-light",
-        dark: "github-dark",
-      },
-      transformers: [transformerNotationDiff()],
-    })) as string
-  })
+  const [html] = createResource(
+    () => [local.code, local.lang],
+    async ([code, lang]) => {
+      return (await codeToHtml(code || "", {
+        lang: lang || "text",
+        themes: {
+          light: "github-light",
+          dark: "github-dark",
+        },
+        transformers: [transformerNotationDiff()],
+      })) as string
+    },
+  )
 
   onCleanup(() => {
     if (containerRef) containerRef.innerHTML = ""
@@ -41,7 +44,13 @@ function CodeBlock(props: CodeBlockProps) {
     }
   })
 
-  return <div ref={containerRef} class={styles.codeblock} {...rest}></div>
+  return (
+    <>
+      {html() ? (
+        <div ref={containerRef} class={styles.codeblock} {...rest}></div>
+      ) : null}
+    </>
+  )
 }
 
 export default CodeBlock
-- 
cgit v1.2.3

