-
-
Notifications
You must be signed in to change notification settings - Fork 416
/
svelte.config.js
62 lines (55 loc) · 1.66 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
62
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
// ☁️ Adapter:
import adapter from '@sveltejs/adapter-node';
// 📦 Extensions:
import { mdsvex, escapeSvelte } from 'mdsvex';
import { createHighlighter, makeSingletonHighlighter } from 'shiki';
// 🎨 Markdown Plugins:
import remarkGfm from 'remark-gfm';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
// 📄 Markdown config:
const getHighlighter = makeSingletonHighlighter(createHighlighter);
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
remarkPlugins: [[remarkGfm]],
rehypePlugins: [
[rehypeSlug],
[
rehypeAutolinkHeadings,
{
behavior: 'wrap',
properties: {
className: [
`before:content-['#'] before:absolute before:-ml-[1em] before:text-neutral-100/0 hover:before:text-neutral-200/50 pl-[1em] -ml-[1em]`
]
}
}
]
],
extensions: ['.md'],
highlight: {
highlighter: async (code, lang = 'text') => {
const highlighter = await getHighlighter({
themes: ['vesper'],
langs: ['javascript', 'typescript', 'bash', 'json']
});
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'vesper' }));
return `{@html \`${html}\` }`;
}
}
};
// 🧡 Svelte config:
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
kit: {
adapter: adapter(),
alias: {
'@': './src/*'
}
}
};
export default config;