UNPKG

meblog

Version:

A simple blog engine for personal blogging

28 lines (27 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const PageTemplate_1 = tslib_1.__importDefault(require("./PageTemplate")); const vinyl_1 = tslib_1.__importDefault(require("vinyl")); const path_1 = tslib_1.__importDefault(require("path")); class PostTemplate extends PageTemplate_1.default { render() { return this.renderPosts(this.dataSource.getPosts(this.template.locale)); } renderPosts(posts) { return posts .filter((p) => p.layout === this.templateName) .map((p) => this.renderPost(p)); } renderPost(post) { if (!this.template.locale) { this.template.locale = post.language; } return new vinyl_1.default({ base: this.template.base, path: path_1.default.join(this.template.base, this.postPartialPath(post)), contents: this.compile(this.template, { post }), }); } } exports.default = PostTemplate;