UNPKG

gpreview

Version:

Preview Ghost themes locally without a full Ghost installation

26 lines 1.31 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.authorsHelper = authorsHelper; const handlebars_1 = __importDefault(require("handlebars")); function authorsHelper(options) { const post = this.post || this; const authors = post.authors || []; if (authors.length === 0) { return new handlebars_1.default.SafeString(''); } const separator = options.hash?.separator || ', '; const prefix = options.hash?.prefix || ''; const suffix = options.hash?.suffix || ''; const limit = options.hash?.limit ? parseInt(String(options.hash.limit), 10) : undefined; const from = options.hash?.from ? parseInt(String(options.hash.from), 10) : 1; const to = options.hash?.to ? parseInt(String(options.hash.to), 10) : undefined; const visibleAuthors = authors.slice(from - 1, to || limit || authors.length); const authorLinks = visibleAuthors.map((author) => { return `<a href="${author.url}" title="${author.name}" class="author">${author.name}</a>`; }).join(separator); return new handlebars_1.default.SafeString(prefix + authorLinks + suffix); } //# sourceMappingURL=authors.js.map