From 6b61e2104f18d212fc700eb109ac212ed1326bff Mon Sep 17 00:00:00 2001 From: pheralb Date: Sat, 9 Mar 2024 12:46:38 +0000 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20Shiki=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svelte.config.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index 2881f85..16dc685 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -3,7 +3,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; // Extensions: import { mdsvex, escapeSvelte } from 'mdsvex'; -import shiki from 'shiki'; +import { getHighlighter } from 'shiki'; // Markdown config: /** @type {import('mdsvex').MdsvexOptions} */ @@ -11,8 +11,12 @@ const mdsvexOptions = { extensions: ['.md'], highlight: { highlighter: async (code, lang = 'text') => { - const highlighter = await shiki.getHighlighter({ theme: 'vitesse-dark' }); - const html = escapeSvelte(highlighter.codeToHtml(code, { lang })); + const highlighter = await getHighlighter({ + themes: ['vitesse-dark'], + langs: ['javascript', 'typescript', 'bash', 'json'] + }); + await highlighter.loadLanguage('javascript', 'typescript', 'bash'); + const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'vitesse-dark' })); return `{@html \`${html}\` }`; } }