-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsvelte.config.js
More file actions
64 lines (59 loc) · 1.31 KB
/
svelte.config.js
File metadata and controls
64 lines (59 loc) · 1.31 KB
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
62
63
64
import preprocess from 'svelte-preprocess';
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { mdsvex } from 'mdsvex';
import { createHighlighter } from 'shiki';
const highlighter = await createHighlighter({
themes: ['catppuccin-latte', 'catppuccin-mocha'],
langs: [
'javascript',
'typescript',
'python',
'bash',
'json',
'html',
'css',
'svelte',
'markdown',
'yaml',
'rust',
'go'
]
});
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [
vitePreprocess(),
preprocess({
postcss: true
}),
mdsvex({
extensions: ['.md'],
highlight: {
highlighter: (code, lang) => {
const html = highlighter.codeToHtml(code, {
lang: lang || 'text',
themes: {
light: 'catppuccin-latte',
dark: 'catppuccin-mocha'
},
defaultColor: false
});
// Escape characters that could break Svelte parsing
const escaped = html
.replace(/\{/g, '{')
.replace(/\}/g, '}')
.replace(/`/g, '`')
.replace(/\$/g, '$');
// Wrap in a div for copy button positioning
return `<div class="code-block">{@html \`${escaped}\`}</div>`;
}
}
})
],
kit: {
adapter: adapter()
}
};
export default config;