blob: b7d45c0570a3f93d79562fafb0c3dac26e0a0356 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import Prism, { highlight, languages } from "prismjs";
import "prismjs/components/prism-swift";
import "prismjs/themes/prism.min.css";
Prism.manual = true;
type Props = {
code: string;
language: string;
};
export default function CodeBlock({ code, language }: Props) {
const highlighted = highlight(code, languages[language]!, language);
return (
<pre className="h-full w-full p-2 bg-gray-50 rounded-lg border border-gray-300 whitespace-pre-wrap break-words">
<code dangerouslySetInnerHTML={{ __html: highlighted }} />
</pre>
);
}
|