blob: 43618f2a0f10efa1911e0a3689147450947ab7d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }} />
);
};
|