-
Notifications
You must be signed in to change notification settings - Fork 6
/
svelte.config.js
50 lines (44 loc) · 1.54 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
import staticAdapter from '@sveltejs/adapter-static';
import vercelAdapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { mdsvex, escapeSvelte } from 'mdsvex';
import remarkUnwrapImages from 'remark-unwrap-images';
import rehypeSlug from 'rehype-slug';
import { codeToHtml, bundledLanguages } from 'shiki';
import { processImages } from 'svelte-enhance-images';
import { processCallouts } from 'svelte-compile-callouts';
import { fixMarkdownUrls } from 'remark-fix-urls';
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extensions: ['.md'],
remarkPlugins: [remarkUnwrapImages, fixMarkdownUrls],
rehypePlugins: [rehypeSlug],
layout: {
_: './src/lib/markdown/base.svelte',
page: './src/lib/markdown/page.svelte',
contents: './src/lib/markdown/contents/contents.svelte',
},
highlight: {
highlighter: async (code, lang = 'text') => {
if (!bundledLanguages[lang]) return code;
const html = escapeSvelte(await codeToHtml(code, { lang, theme: 'night-owl' }));
return `{@html \`${html}\` }`;
},
},
};
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions), processImages(), processCallouts()],
kit: {
adapter: process.env.VERCEL ? vercelAdapter() : staticAdapter({ strict: false }),
alias: {
'@/*': 'src/*',
'$lib/*': 'src/lib/*',
'$assets/*': 'src/assets/*',
'$courses/*': 'content/courses/*',
'content/*': 'content/*',
},
},
};
export default config;