-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvelte.config.js
76 lines (70 loc) · 1.88 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { mdsvex, escapeSvelte } from 'mdsvex';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import rehypeExternalLinks from 'rehype-external-links';
import remarkAbbr from 'remark-abbr';
import { transformerTwoslash } from '@shikijs/twoslash';
import { codeToHtml } from 'shiki';
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.svx', '.md', '.mdx'],
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [
vitePreprocess(),
mdsvex({
extensions: ['.svx', '.mdx'],
smartypants: {
dashes: 'oldschool'
},
highlight: {
highlighter: async (code, lang = 'text') => {
const twoslashable = [
'js',
'javascript',
'ts',
'typescript',
'tsx',
'jsx',
'json',
'jsn'
].includes(lang);
let rendered = '';
if (twoslashable) {
try {
rendered = await codeToHtml(code, {
lang,
theme: 'vitesse-dark',
transformers: [transformerTwoslash()]
});
} catch (e) {
throw Error('Could not transform code: \n' + code, { cause: e });
}
} else {
rendered = await codeToHtml(code, { lang, theme: 'vitesse-dark' });
}
const html = escapeSvelte(rendered);
return `{@html \`${html}\` }`;
}
},
rehypePlugins: [
[rehypeSlug, undefined],
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
[rehypeExternalLinks, { target: '_blank', rel: ['noopener', 'noreferrer'] }]
],
remarkPlugins: [remarkAbbr]
})
],
kit: {
adapter: adapter(),
typescript: {
config: (conf) => {
conf.include.push('../plugins/**/*.d.ts');
return conf;
}
}
}
};
export default config;