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:
|
// Extensions:
|
||||||
import { mdsvex, escapeSvelte } from 'mdsvex';
|
import { mdsvex, escapeSvelte } from 'mdsvex';
|
||||||
import shiki from 'shiki';
|
import { getHighlighter } from 'shiki';
|
||||||
|
|
||||||
// Markdown config:
|
// Markdown config:
|
||||||
/** @type {import('mdsvex').MdsvexOptions} */
|
/** @type {import('mdsvex').MdsvexOptions} */
|
||||||
@ -11,8 +11,12 @@ const mdsvexOptions = {
|
|||||||
extensions: ['.md'],
|
extensions: ['.md'],
|
||||||
highlight: {
|
highlight: {
|
||||||
highlighter: async (code, lang = 'text') => {
|
highlighter: async (code, lang = 'text') => {
|
||||||
const highlighter = await shiki.getHighlighter({ theme: 'vitesse-dark' });
|
const highlighter = await getHighlighter({
|
||||||
const html = escapeSvelte(highlighter.codeToHtml(code, { lang }));
|
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}\` }`;
|
return `{@html \`${html}\` }`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user