-
Notifications
You must be signed in to change notification settings - Fork 90
/
svelte.config.js
46 lines (43 loc) · 1.16 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
/** @type {import('@sveltejs/kit').Config} */
import { replace } from 'svelte-preprocess';
import { readFileSync } from 'fs';
import { resolve } from 'path';
import static_adapter from '@sveltejs/adapter-static';
import Prism from 'prismjs';
import 'prism-svelte';
const config = {
kit: {
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
paths: !process.env.DEPLOY
? {}
: {
base: '/svelte-calendar',
assets: '/svelte-calendar'
},
appDir: 'internal',
adapter: static_adapter({
pages: 'docs',
assets: 'docs',
fallback: null
})
},
preprocess: [
replace([
[
/\/\/\s+\@example\((.*), (.*)\)/g,
(_, name, path) => {
const text = readFileSync(resolve('./src/lib/docs/examples', path), 'utf-8')
.replace(/\'\.\.\/\.\.\/index\'/g, "'svelte-calendar'")
.split(/\<!\-\- Example Notes \-\-\>/)
.shift();
const highlighted = Prism.highlight(text, Prism.languages.svelte, 'svelte');
return `
import ${name}Comp from '$lib/docs/examples/${path}';
const ${name} = { component: ${name}Comp, code: ${JSON.stringify(highlighted)}}`;
}
]
])
]
};
export default config;