⬆️ Upgrade Shiki config

This commit is contained in:
pheralb 2024-03-09 12:46:38 +00:00
parent e7bc95b6f5
commit 6b61e2104f

View File

@ -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}\` }`;
}
}