summaryrefslogtreecommitdiffhomepage
path: root/app/packages/web/src/components/CodeBlock.tsx
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-30 20:47:56 -0400
committerDax Raad <[email protected]>2025-05-30 20:48:36 -0400
commitf3da73553c45f17e04b1e77cb13eb0fca714d1bd (patch)
treea24317a19e1ab2a89da50db669dc6894f15d00d1 /app/packages/web/src/components/CodeBlock.tsx
parent9a26b3058ffc1023e5c7e54b6d571c903d15888e (diff)
downloadopencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.tar.gz
opencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.zip
sync
Diffstat (limited to 'app/packages/web/src/components/CodeBlock.tsx')
-rw-r--r--app/packages/web/src/components/CodeBlock.tsx47
1 files changed, 0 insertions, 47 deletions
diff --git a/app/packages/web/src/components/CodeBlock.tsx b/app/packages/web/src/components/CodeBlock.tsx
deleted file mode 100644
index 17559ece1..000000000
--- a/app/packages/web/src/components/CodeBlock.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import {
- type JSX,
- onCleanup,
- splitProps,
- createEffect,
- createResource,
-} from "solid-js"
-import { codeToHtml } from "shiki"
-import { transformerNotationDiff } from '@shikijs/transformers'
-
-interface CodeBlockProps extends JSX.HTMLAttributes<HTMLDivElement> {
- code: string
- lang?: string
-}
-function CodeBlock(props: CodeBlockProps) {
- const [local, rest] = splitProps(props, ["code", "lang"])
- let containerRef!: HTMLDivElement
-
- const [html] = createResource(async () => {
- return (await codeToHtml(local.code, {
- lang: local.lang || "text",
- themes: {
- light: 'github-light',
- dark: 'github-dark',
- },
- transformers: [
- transformerNotationDiff(),
- ],
- })) as string
- })
-
- onCleanup(() => {
- if (containerRef) containerRef.innerHTML = ""
- })
-
- createEffect(() => {
- if (html() && containerRef) {
- containerRef.innerHTML = html() as string
- }
- })
-
- return (
- <div ref={containerRef} {...rest}></div>
- )
-}
-
-export default CodeBlock