-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsvelte.config.js
More file actions
68 lines (64 loc) · 1.39 KB
/
svelte.config.js
File metadata and controls
68 lines (64 loc) · 1.39 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
65
66
67
68
import { mdsvex } from 'mdsvex';
import adapter from '@sveltejs/adapter-static';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import { createHighlighter } from 'shiki';
import { baseRewrite } from './src/lib/preprocess-base-rewrite.js';
const shiki = await createHighlighter({
themes: ['github-dark'],
langs: [
'python',
'typescript',
'javascript',
'svelte',
'html',
'css',
'bash',
'shell',
'json',
'yaml',
'text'
]
});
/**
* @param {string} code
* @param {string | undefined} lang
*/
function highlighter(code, lang) {
const resolved = lang && shiki.getLoadedLanguages().includes(lang) ? lang : 'text';
const html = shiki.codeToHtml(code, { lang: resolved, theme: 'github-dark' });
return html.replace(/\{/g, '{').replace(/\}/g, '}');
}
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: '404.html',
strict: false
}),
paths: {
base: process.env.BASE_PATH ?? ''
},
prerender: {
handleHttpError: 'warn',
handleMissingId: 'warn',
handleUnseenRoutes: 'warn'
}
},
preprocess: [
baseRewrite(),
mdsvex({
highlight: {
highlighter
},
rehypePlugins: [
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: 'wrap' }]
]
})
],
extensions: ['.svelte', '.svx']
};
export default config;