-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdsvex.config.js
33 lines (31 loc) · 888 Bytes
/
mdsvex.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
import fs from 'fs';
import { mdsvex } from 'mdsvex';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeKatex from 'rehype-katex-svelte';
import remarkAdmonitions from 'remark-admonitions';
import remarkEmoji from 'remark-emoji';
import remarkMath from 'remark-math';
const ADMONITION_ICON_PATH = './src/lib/assets/admonitions-icon/';
const customTypes = Object.fromEntries(
fs.readdirSync(ADMONITION_ICON_PATH).map((file) => [
file.split('.')[0],
{
svg: fs
.readFileSync(ADMONITION_ICON_PATH + file)
.toString()
.replaceAll(/[\r\n]| {2}/g, '')
}
])
);
export default mdsvex({
extensions: ['.md'],
remarkPlugins: [
remarkEmoji,
remarkMath,
[remarkAdmonitions, { customTypes }]
],
rehypePlugins: [
rehypeKatex,
[rehypeExternalLinks, { rel: ['noopener noreferrer'], target: '_blank' }]
]
});