Ghost/core/server/lib/mobiledoc/cards/embed.js
2018-06-12 16:18:01 +01:00

26 lines
638 B
JavaScript

module.exports = {
name: 'embed',
type: 'dom',
render(opts) {
if (!opts.payload.html) {
return '';
}
let {payload, env: {dom}} = opts;
let figure = dom.createElement('figure');
figure.setAttribute('class', 'kg-embed-card');
let html = dom.createRawHTMLSection(payload.html);
figure.appendChild(html);
if (payload.caption) {
let figcaption = dom.createElement('figcaption');
figcaption.appendChild(dom.createTextNode(payload.caption));
figure.appendChild(figcaption);
}
return figure;
}
};