summaryrefslogtreecommitdiff
path: root/mdsvex.config.js
blob: 74762592558062b5f614460236b4c83b0f7a2f9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { createHighlighter } from 'shiki';

const highlighter = await createHighlighter({
    themes: ['ayu-dark'],
    langs: ['javascript', 'typescript', 'svelte', 'html', 'css', 'bash', 'json', 'yaml', 'markdown', 'python']
});

/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexConfig = {
    extensions: ['.svx'],
    highlight: {
        highlighter: async (code, lang) => {
            const html = highlighter.codeToHtml(code, {
                lang: lang || 'text',
                theme: 'ayu-dark'
            });
            return `{@html \`${html.replace(/[{}`]/g, (c) => `&#${c.charCodeAt(0)};`)}\`}`;
        }
    }
};

export default mdsvexConfig;