0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/lib/mobiledoc/cards/embed.js

29 lines
807 B
JavaScript
Raw Normal View History

const createCard = require('../create-card');
module.exports = createCard({
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-card 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);
figure.setAttribute('class', `${figure.getAttribute('class')} kg-card-hascaption`);
}
return figure;
}
});