mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
fe8c07333d
refs https://github.com/TryGhost/Ghost/issues/9623 - add `embed` card renderer
26 lines
638 B
JavaScript
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;
|
|
}
|
|
};
|