-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdsvex.config.js
60 lines (57 loc) · 1.74 KB
/
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
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
import { escapeSvelte } from "mdsvex";
import { getSingletonHighlighter } from "shiki";
import {
transformerNotationFocus,
transformerNotationDiff,
transformerMetaHighlight,
transformerMetaWordHighlight
} from "@shikijs/transformers";
import rehypeUnwrapImages from "rehype-unwrap-images";
import rehypeSlug from "rehype-slug";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import remarkToc from "./src/lib/remarkToc.js";
import remarkSubSuper from "remark-sub-super";
import remarkIns from "remark-ins";
import remarkFootnotes from "remark-footnotes";
import readingTime from "mdsvex-reading-time";
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extension: ".md",
highlight: {
highlighter: async (code, lang, metastring) => {
const withTitle = (metastring || '').match(/title="([^"]+)"/);
const highlighter = await getSingletonHighlighter({
themes: ["github-dark"],
langs: [lang]
});
const html = escapeSvelte(highlighter.codeToHtml(code, {
lang: lang,
theme: "github-dark",
transformers: [
transformerNotationFocus(),
transformerNotationDiff(),
transformerMetaHighlight(),
transformerMetaWordHighlight()
],
meta: { __raw: metastring }
}));
return `{@html \`<figure class="shiki-block" data-lang="${lang}">
${withTitle ? `<figcaption class="shiki-block-title">${withTitle[1]}</figcaption>` : ''}
${html}
</figure>\` }`;
}
},
remarkPlugins: [
[remarkToc, { tight: true, maxDepth: 3 }],
remarkSubSuper,
remarkIns,
remarkFootnotes,
readingTime
],
rehypePlugins: [
rehypeSlug,
rehypeAutolinkHeadings,
rehypeUnwrapImages
]
};
export default mdsvexOptions;