mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs https://github.com/TryGhost/Ghost/issues/9724 - captions can have HTML so we need to render as HTML rather than as a text node so special chars don't get escaped
25 lines
644 B
JavaScript
25 lines
644 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.createRawHTMLSection(payload.caption));
|
|
figure.appendChild(figcaption);
|
|
}
|
|
|
|
return figure;
|
|
}
|
|
};
|