/ svelte.config.js
svelte.config.js
 1  import adapter from "@sveltejs/adapter-static";
 2  import rehypeSlug from "rehype-slug";
 3  import remarkUnwrapImages from "remark-unwrap-images";
 4  import { getSingletonHighlighter } from "shiki";
 5  import { mdsvex, escapeSvelte } from "mdsvex";
 6  import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
 7  
 8  const mdsvexOptions = {
 9    extensions: [".md"],
10    highlight: {
11      highlighter: async (code, lang = "text") => {
12        const highlighter = await getSingletonHighlighter({
13          themes: ["github-dark"],
14          langs: ["bash", "sh"],
15        });
16        const html = escapeSvelte(
17          highlighter.codeToHtml(code, { lang, theme: "github-dark" }),
18        );
19        return `{@html \`${html}\` }`;
20      },
21    },
22    remarkPlugins: [remarkUnwrapImages],
23    rehypePlugins: [rehypeSlug],
24  };
25  
26  export default {
27    extensions: [".svelte", ".md"],
28    preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
29    kit: {
30      adapter: adapter(),
31    },
32  };