UNPKG

npf2html

Version:

Converts Tumblr's Neue Post Format to plain HTML

32 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renderAttribution = renderAttribution; /** Converts {@link attribution} to HTML. */ function renderAttribution(renderer, attribution) { const href = attribution.type === 'blog' ? attribution.blog.url : attribution.url; let result = `<a class="${renderer.prefix}-attribution` + ` ${renderer.prefix}-attribution-${attribution.type}"` + ` href="${renderer.escape(href)}">`; switch (attribution.type) { case 'post': case 'blog': result += renderer.escape(attribution.blog.name); break; case 'link': result += renderer.escape(attribution.url); break; case 'app': { const display = attribution.display_text || attribution.app_name; if (display) result += renderer.escape(display); if (attribution.logo) { result += renderer.renderImageMedia([attribution.logo]); } else if (!display) { result += renderer.escape(attribution.url); } } } return result + '</a>'; } //# sourceMappingURL=attribution.js.map