-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvelte.config.js
37 lines (33 loc) · 1.09 KB
/
svelte.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import adapter from "@sveltejs/adapter-static"
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"
import { unified } from "unified"
import remarkParse from "remark-parse"
import remarkRehype from "remark-rehype"
import rehypeStringify from "rehype-stringify"
import rehypeShiki from "@shikijs/rehype"
const mdToHTML = async (content) =>
await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeShiki, { theme: "github-dark-default", langs: ["js"] })
.use(rehypeStringify)
.process(content)
const mdxPreprocess = () => {
return {
markup: async ({ content, filename }) => {
if (!filename.endsWith(".md")) return
const html = await mdToHTML(content)
return { code: html.value }
},
}
}
/** @type {import("@sveltejs/kit").Config} */
export default {
extensions: [".svelte", ".md"],
kit: { adapter: adapter() },
preprocess: [mdxPreprocess(), vitePreprocess()],
onwarn: (warning, handler) => {
if (warning.code.startsWith("a11y-")) return
handler(warning)
},
}