diff options
author | 2022-08-05 02:37:34 -0500 | |
---|---|---|
committer | 2022-08-05 00:37:34 -0700 | |
commit | 95294d245c87bf135c715a46c9559805f39d90ef (patch) | |
tree | 2f2794ddb57448737952bfd6b8802b1f9e5bc4fa /packages/bun-landing/components/CodeBlock.tsx | |
parent | c5b600ad483b9276e8dc651dd4f35ecd7b56f8a1 (diff) | |
download | bun-95294d245c87bf135c715a46c9559805f39d90ef.tar.gz bun-95294d245c87bf135c715a46c9559805f39d90ef.tar.zst bun-95294d245c87bf135c715a46c9559805f39d90ef.zip |
Convert landing page to zero-JS Next.js application. (#945)
Diffstat (limited to 'packages/bun-landing/components/CodeBlock.tsx')
-rw-r--r-- | packages/bun-landing/components/CodeBlock.tsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/bun-landing/components/CodeBlock.tsx b/packages/bun-landing/components/CodeBlock.tsx new file mode 100644 index 000000000..43618f2a0 --- /dev/null +++ b/packages/bun-landing/components/CodeBlock.tsx @@ -0,0 +1,15 @@ +import * as shiki from "shiki"; + +// because we don't want to wait for it to reload everytime this page reloads +globalThis._highlighter ||= await shiki.getHighlighter({ + theme: "dracula", +}); + +const highlighter = globalThis._highlighter as shiki.Highlighter; + +export default function CodeBlock({ children, lang = "js" }) { + const html = highlighter.codeToHtml(children.trim(), { lang }); + return ( + <div className="CodeBlock" dangerouslySetInnerHTML={{ __html: html }} /> + ); +};
\ No newline at end of file |