From 927cbdca6d1dc84d310bcf2614714437ffa5469b Mon Sep 17 00:00:00 2001 From: pheralb Date: Wed, 13 Dec 2023 23:42:17 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20markdown=20&=20extensions?= =?UTF-8?q?=20config.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svelte.config.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index d64f9eb..0dc4ade 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,13 +1,32 @@ import adapter from '@sveltejs/adapter-auto'; import { vitePreprocess } from '@sveltejs/kit/vite'; +// Extensions: +import { mdsvex, escapeSvelte } from 'mdsvex'; +import shiki from 'shiki'; + +// Markdown config: +/** @type {import('mdsvex').MdsvexOptions} */ +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 })); + return `{@html \`${html}\` }`; + } + } +}; + +// Svelte config: /** @type {import('@sveltejs/kit').Config} */ const config = { - preprocess: vitePreprocess(), + extensions: ['.svelte', '.md'], + preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)], kit: { adapter: adapter(), alias: { - '@': './src/*', + '@': './src/*' } } };