-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (23 loc) · 652 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
/**
* Wraps html in tag with specific class name.
*
* @param {String} html
* @param {Object} attrs
* @return {String} HTML wrapped in a container
*/
function wrapInContainer (html, {element, className}) {
return `<${element} class="${className}">${html}</${element}>`
}
module.exports = {
blocks: {
wrap: {
process: function (block) {
const pluginConfig = this.config.get('pluginsConfig.wrapper')
const attrs = Object.assign({}, pluginConfig, block.kwargs)
return this
.renderBlock('markdown', block.body)
.then(renderedBody => wrapInContainer(renderedBody, attrs))
}
}
}
}