aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/Gaming/CodeBlock.tsx
blob: b193774db8d1abe1413b7dd3cedb16055e9f092b (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="bg-white resize-none h-full w-full rounded-lg border border-gray-300 p-2">
			<code dangerouslySetInnerHTML={{ __html: highlighted }} />
		</pre>
	);
}