mirror of
https://github.com/pheralb/svgl.git
synced 2025-02-06 06:58:04 +08:00
⬆️ Upgrade Shiki config
This commit is contained in:
parent
e7bc95b6f5
commit
6b61e2104f
@ -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}\` }`;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user