-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdsvex.config.js
49 lines (47 loc) · 1.22 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
import { visit } from 'unist-util-visit'
import autolinkHeadings from 'rehype-autolink-headings'
import slugPlugin from 'rehype-slug'
import relativeImages from 'mdsvex-relative-images'
import remarkExternalLinks from 'remark-external-links';
import readingTime from 'remark-reading-time';
export default {
extensions: ['.svx', '.md'],
smartypants: {
dashes: 'oldschool'
},
layout: {
_: "/src/markdown-layouts/default.svelte",
// blog: "/src/markdown-layouts/blog.svelte",
// project: "/src/markdown-layouts/project.svelte",
},
remarkPlugins: [
videos,
relativeImages,
readingTime,
[remarkExternalLinks, { target: '_blank', rel: 'noopener' }],
],
rehypePlugins: [
slugPlugin,
[autolinkHeadings, { behavior: 'wrap' }]
]
}
function videos() {
const extensions = ['mp4', 'webm']
return function transformer(tree) {
visit(tree, 'image', (node) => {
if (extensions.some((ext) => node.url.endsWith(ext))) {
node.type = 'html'
node.value = `
<video
src="${node.url}"
autoplay
muted
playsinline
loop
title="${node.alt}"
/>
`
}
})
}
}