-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmdsvex.config.js
31 lines (26 loc) · 897 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
import { defineMDSveXConfig as defineConfig, escapeSvelte } from 'mdsvex';
import slug from 'rehype-slug';
import externalLinks from 'remark-external-links';
import { getHighlighter } from 'shiki';
const config = defineConfig({
extensions: ['.md'],
highlight: {
highlighter: async (code, lang = 'text') => {
const highlighter = await getHighlighter({
themes: ['github-dark', 'github-light'],
langs: ['javascript', 'typescript', 'svelte', 'css', 'text']
});
await highlighter.loadLanguage('javascript', 'typescript');
const html = escapeSvelte(
highlighter.codeToHtml(code, { lang, themes: { light: 'github-light', dark: 'github-dark' } })
);
return `{@html \`${html}\` }`;
}
},
smartypants: {
dashes: 'oldschool'
},
remarkPlugins: [[externalLinks, { target: '_blank', rel: 'noopener noreferrer' }]],
rehypePlugins: [slug]
});
export default config;