UNPKG

gpreview

Version:

Preview Ghost themes locally without a full Ghost installation

26 lines 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.tagsHelper = tagsHelper; const handlebars_1 = __importDefault(require("handlebars")); function tagsHelper(options) { const post = this.post || this; const tags = post.tags || []; if (tags.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 visibleTags = tags.slice(from - 1, to || limit || tags.length); const tagLinks = visibleTags.map((tag) => { return `<a href="${tag.url}" title="${tag.name}" class="tag tag-${tag.slug}">${tag.name}</a>`; }).join(separator); return new handlebars_1.default.SafeString(prefix + tagLinks + suffix); } //# sourceMappingURL=tags.js.map