-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvelte.config.js
61 lines (56 loc) · 1.83 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { mdsvex, escapeSvelte } from 'mdsvex';
import remarkToc from 'remark-toc';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { createHighlighter } from 'shiki';
import remarkCodeTitles from "remark-flexible-code-titles";
import adapter from '@sveltejs/adapter-vercel';
// import rehypePrettyCode from 'rehype-pretty-code';
// import {
// transformerCopyButton,
// transformerFoldableLines,
// } from '@rehype-pretty/transformers';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({})
},
extensions: ['.svelte', '.svx', '.md'],
preprocess: [
mdsvex({
extensions: ['.md', '.svx'],
highlight: {
highlighter: async (code, lang = 'text') => {
const theme = 'tokyo-night';
const highlighter = await createHighlighter({ themes: [theme] })
await highlighter.loadLanguage(lang)
await highlighter.loadTheme(theme)
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme }))
highlighter.dispose()
return `{@html \`${html}\` }`
}
},
remarkPlugins: [remarkToc, [remarkCodeTitles, { tokenForSpaceInTitle: "@", }]],
rehypePlugins: [
rehypeSlug,
rehypeAutolinkHeadings,
// Rehype pretty code does not work :(
// [rehypePrettyCode, {
// keepBackground: false,
// transformers: [
// transformerCopyButton({
// visibility: 'always',
// feedbackDuration: 2_500,
// }),
// transformerFoldableLines({
// lines: [[1, 2]],
// }),
// ],
// }]
]
}),
vitePreprocess(),
]
};
export default config;