UNPKG

gpreview

Version:

Preview Ghost themes locally without a full Ghost installation

23 lines 935 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.contentHelper = contentHelper; const handlebars_1 = __importDefault(require("handlebars")); function contentHelper(options) { const post = this.post || this.page || this; if (!post || !('html' in post) || !post.html) { return new handlebars_1.default.SafeString(''); } let content = post.html; if (options.hash?.words) { const words = parseInt(String(options.hash.words), 10); const contentWords = content.replace(/<[^>]*>/g, '').split(/\s+/); if (contentWords.length > words) { content = contentWords.slice(0, words).join(' ') + '...'; } } return new handlebars_1.default.SafeString(content); } //# sourceMappingURL=content.js.map