import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/kit/vite'; import {mdsvex} from "mdsvex"; function escapeBraces(unsafe) { return unsafe .replace(/{/g, "{") .replace(/}/g, "}"); } function highlighter(code, lang) { // Lang can be: // just the lang ('rust') // the lang, then in brackets lines to hightlight ('rust[1-5,9,21-23]') let params = new URLSearchParams(lang.split('?')[1]); let real_lang = lang.split('?')[0]; let classes = [`language-${real_lang}`]; let props = ""; if (params.has("lines")) { props += `data-line="${params.get("lines")}" `; } if (params.has("src")) { props += `data-src="${params.get("src")}" `; } if (params.has("enableDownload")) { props += "data-download-link "; } if (params.has("downloadLabel")) { props += `data-download-link-label="${params.get("downloadLabel")}" `; } return `
${escapeBraces(code)}
` } /** @type {import('@sveltejs/kit').Config} */ const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors // for more information about preprocessors preprocess: [ vitePreprocess(), mdsvex({ extensions: ['.svx'], layout: './src/lib/PostLayout.svelte', highlight: { highlighter } }) ], extensions: ['.svelte', '.svx'], kit: { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. adapter: adapter(), alias: { "$components": "src/components" } } }; export default config;