We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c22cd7d commit 02bca04Copy full SHA for 02bca04
src/lib/components/Highlight.svelte
@@ -1,14 +1,15 @@
1
<script lang="ts">
2
import type { BundledLanguage, BundledTheme } from "shiki";
3
4
+ import { cached } from "$lib/utils/cache";
5
import { getSingletonHighlighter } from "shiki";
6
7
export let lang: BundledLanguage | "ansi" | "text";
8
export let source: string;
9
export let theme: BundledTheme = "vesper";
10
11
async function highlight(source: string) {
- const highlighter = await getSingletonHighlighter({ langs: [lang], themes: [theme] });
12
+ const highlighter = await cached(lang + theme)(() => getSingletonHighlighter({ langs: [lang], themes: [theme] }))();
13
14
return highlighter.codeToHtml(source, { lang, theme });
15
}
0 commit comments