"use strict"; const fs = require("fs"); const hyperfast = require("hyperfast"); const indent = require("indent-string"); const getTemplate = name => fs.readFileSync(`${__dirname}/templates/${name}.html`, "utf8"); function getTemplateIndent(re, template) { return re.exec(getTemplate(template))[1].length; } const findMain = /^(\s+)
post => ({ a: { href: ctx.getURL(post, post.basename), _text: post.data.get("title") } }); function layout(config, pageTitle, pageElement) { return hyperfast(templates.layout, { title: title(config.site.author.name, pageTitle), "body > header .p-name": config.site.author.name, "body > header .u-photo": { alt: config.site.author.name, src: config.site.author.photo }, "body > main": pageElement }).outerHTML.trim(); } module.exports = { baseIndentLevel, postIndentLevel, indentForTemplate, home(ctx, config, posts) { ctx.type = "html"; ctx.body = layout( config, null, hyperfast(templates.home, { ".post": posts.map(renderPostListItem(ctx)) }) ); }, post(ctx, config, post) { ctx.type = "html"; ctx.body = layout( config, post.data.get("title"), hyperfast(templates.post, { "article h1": post.data.get("title"), "article .post-content": { _html: post.body } }) ); }, taxon(ctx, config, taxonItems) { ctx.type = "html"; ctx.body = layout( config, null, hyperfast(templates.taxon, { ".post": taxonItems.map(renderPostListItem(ctx)) }) ); } };