diff options
Diffstat (limited to 'mdsvex.config.js')
| -rw-r--r-- | mdsvex.config.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mdsvex.config.js b/mdsvex.config.js new file mode 100644 index 0000000..e936267 --- /dev/null +++ b/mdsvex.config.js @@ -0,0 +1,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; |
