npf2html
Version:
Converts Tumblr's Neue Post Format to plain HTML
35 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderAskLayout = renderAskLayout;
/**
* Wraps {@link html} as an ask.
*
* @category Layout
*/
function renderAskLayout(renderer, layout, html) {
var _a, _b, _c;
let result = `<div class="${renderer.prefix}-layout-ask">`;
if (layout.attribution) {
result += `<a href="${renderer.escape(layout.attribution.blog.url)}">`;
}
else {
// Always wrap the avatar in an A tag even if there's nothing to link to to
// make it easier to style consistently.
result += '<a>';
}
result +=
renderer.renderImageMedia(renderer.askingAvatar) +
'</a><figure><figcaption>';
if (layout.attribution) {
result += `<a href="${renderer.escape(layout.attribution.blog.url)}">`;
}
result +=
'<strong>' +
renderer.escape((_c = (_b = (_a = layout.attribution) === null || _a === void 0 ? void 0 : _a.blog) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : 'Anonymous') +
'</strong> asked:';
if (layout.attribution)
result += '</a>';
result += '</figcaption>' + html + '</figure></div>';
return result;
}
//# sourceMappingURL=ask-layout.js.map