From ac0d9a5a030c5eb1bbc493f26b13b1c126e02a3e Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 15 Oct 2024 19:27:40 -0700 Subject: [PATCH] feat: Cache shiki instance; Add more languages --- svelte.config.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index e9e218d..9820d65 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,18 +11,31 @@ import { getHighlighter } from 'shiki' const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content"; const langs = [ - "rust", + "javascript", + "lean", + "lisp", "nix", "python", - "lean", - "javascript", + "rust", + "toml", "typescript", + "yaml", + "c", + "c++", + "sh", ]; const highlightingThemes = { light: 'vitesse-light', dark: 'vitesse-dark', }; +const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] }); +const highlighter = await getHighlighter({ + themes, + langs, +}) +await highlighter.loadLanguage(...langs); + /** @type {import('@sveltejs/kit').Config} */ const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors @@ -40,12 +53,6 @@ const config = { ], highlight: { highlighter: async (code, lang = 'text') => { - const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] }); - const highlighter = await getHighlighter({ - themes, - langs, - }) - await highlighter.loadLanguage(...langs); const html = escapeSvelte(highlighter.codeToHtml(code, { lang, themes: highlightingThemes,