-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdsvex.config.js
38 lines (32 loc) · 983 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
34
35
36
37
38
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import toc from '@jsdevtools/rehype-toc';
function headings() {
let visit;
let tree_to_string;
return async function transformer(tree, vFile) {
if (!visit) {
tree_to_string = (await import('mdast-util-to-string')).toString;
visit = (await import('unist-util-visit')).visit;
}
vFile.data.headings = [];
visit(tree, 'heading', (node) => {
vFile.data.headings.push({
level: node.depth,
title: tree_to_string(node),
});
});
if (!vFile.data.fm) vFile.data.fm = {};
vFile.data.fm.headings = vFile.data.headings;
};
}
const mdsvexConfig = {
extensions: ['.svelte.md', '.md', '.svx'],
smartypants: {
dashes: 'oldschool',
},
layout: 'src/lib/components/layout/GuideLayout.svelte',
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings],
remarkPlugins: [headings],
};
export default mdsvexConfig;