summaryrefslogtreecommitdiff
path: root/mdsvex.config.js
blob: e936267938d84636e2d8674953462c848469dad5 (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']
});

/** @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;