-
Notifications
You must be signed in to change notification settings - Fork 21
/
svelte.config.js
111 lines (104 loc) · 2.76 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import adapter from '@sveltejs/adapter-static'
import { s } from 'hastscript'
import { mdsvex } from 'mdsvex'
import link_headings from 'rehype-autolink-headings'
import katex from 'rehype-katex-svelte'
import heading_slugs from 'rehype-slug'
import math from 'remark-math'
import preprocess from 'svelte-preprocess'
import { importAssets } from 'svelte-preprocess-import-assets'
const macros = {
// Infinitesimal differential (used in derivatives and integrals)
'\\dif': `\\mathrm d`,
// Vector
'\\vec': `{\\boldsymbol{#1}}`,
// Matrix
'\\mat': `{\\boldsymbol{#1}}`,
// Real line
'\\reals': `{\\mathbb{R}}`,
// Complex plane
'\\comps': `{\\mathbb{C}}`,
// Integers
'\\ints': `{\\mathbb{Z}}`,
// Expectation value
'\\expect': `\\mathbb{E}`,
// Variance
'\\var': `\\operatorname{var}`,
// Matrix diagonal
'\\diag': `\\operatorname{diag}`,
// Unit/identity matrix
'\\unity': `\\mat{\\mathbb{I}}`,
// Used in equations to hide non-essential constants
'\\const': `\\text{const}`,
// Absolute value
'\\abs': `\\left|#1\\right|`,
// Adaptive parentheses
'\\paren': `\\mathopen{}\\left(#1\\right)\\mathclose{}`,
// Adaptive brackets
'\\brkt': `\\mathopen{}\\left[#1\\right]\\mathclose{}`,
// Adaptive curly brackets
'\\cbrkt': `\\mathopen{}\\left\\{#1\\right\\}\\mathclose{}`,
}
for (let index = `A`.charCodeAt(); index <= `Z`.charCodeAt(); index++) {
const letter = String.fromCharCode(index)
// Caligraphic letters
macros[`\\${letter}cal`] = `\\mathcal{${letter}}`
// Blackboard bold letters
macros[`\\${letter}bb`] = `\\mathbb{${letter}}`
}
const rehypePlugins = [
[
katex,
{
macros,
throwOnError: false,
errorColor: `#cc0000`,
},
],
heading_slugs,
[
link_headings,
{
behavior: `append`,
test: [`h2`, `h3`, `h4`, `h5`, `h6`], // don't auto-link <h1>
content: s(
`svg`,
{ width: 16, height: 16, viewBox: `0 0 16 16` },
// symbol #octicon-link defined in app.html
s(`use`, { 'xlink:href': `#octicon-link` }),
),
},
],
]
/** @type {import('@sveltejs/kit').Config} */
export default {
extensions: [`.svelte`, `.svx`, `.md`],
preprocess: [
preprocess(),
mdsvex({
rehypePlugins,
// [email protected] pinned due to mdsvex, see
// https://github.com/kwshi/rehype-katex-svelte#usage
remarkPlugins: [math],
extensions: [`.svx`, `.md`],
}),
importAssets({
sources: (default_sources) => {
return [
...default_sources,
{
tag: `a`,
srcAttributes: [`href`],
filter: (node) => node.attributes?.href.endsWith(`.pdf`),
},
]
},
}),
],
kit: {
adapter: adapter(),
alias: {
$root: `.`,
},
},
}