-
Notifications
You must be signed in to change notification settings - Fork 3
/
_config.ts
55 lines (48 loc) · 1.31 KB
/
_config.ts
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
import lume from 'lume/mod.ts';
import date from 'lume/plugins/date.ts';
import codeHighlight from 'lume/plugins/code_highlight.ts';
import markdownItAnchor from 'https://jspm.dev/markdown-it-anchor';
import cheerio from 'https://jspm.dev/cheerio';
const site = lume({
location: new URL('https://velociraptor.run'),
}, {
markdown: {
plugins: [
[markdownItAnchor, {
permalink: true,
permalinkBefore: true,
permalinkSymbol: '#',
permalinkSpace: false,
}],
],
},
});
site.use(date());
site.use(codeHighlight());
site.copy('static', '');
site.filter('groups', items => items.reduce((grouped, item) => {
const {group} = item.data;
(grouped[group] = grouped[group] || []).push(item);
return grouped;
}, {})
);
site.filter('toc', content => {
const $ = cheerio.load(content);
const toc = [];
$('h1[id],h2[id],h3[id]').each((_, el) => {
const $el = $(el);
toc.push({
level: Number(el.name.substring(1)),
anchor: $el.attr('id'),
text: $el.text().replace(/^#/, ''),
});
});
return toc;
});
site.data('vrVersion', () => {
return fetch('https://api.github.com/repos/jurassiscripts/velociraptor/releases/latest')
.then(r => r.json())
.then(r => r.name);
});
site.filter('await', promise => promise, true);
export default site;