-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 loc) · 893 Bytes
/
index.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
module.exports = {
website: {
assets: "./assets",
js: [
"collapse.js"
],
css: [
"collapse.css"
]
},
blocks: {
collapse: {
process: function (blk) {
const open = this.output.name !== 'website'
const processMarkDown = blk.kwargs.process !== false
const title = blk.kwargs.title || ''
function format(body, summary, shouldOpen) {
const openTag = shouldOpen === true ? 'open': ''
summary = summary || ''
body = body || ''
return '<details ' + openTag + '><summary>' + summary + '</summary>' + body + '</details>';
}
return processMarkDown === false ?
format(blk.body, title) :
this.renderBlock('markdown', blk.body, open)
.then(function (data) {
return format(data, title, open)
});
}
}
}
};