UNPKG

hikaru-coffee

Version:

A static site generator that generates routes based on directories naturally.

47 lines (41 loc) 1.03 kB
// Generated by CoffeeScript 2.3.1 (function() { var Generator; module.exports = Generator = class Generator { constructor(logger) { // fn: param page, pages, ctx, return Promise this.register = this.register.bind(this); this.generate = this.generate.bind(this); this.logger = logger; this.store = {}; } register(layout, fn) { var i, l, len; if (!(fn instanceof Function)) { return; } if (layout instanceof Array) { for (i = 0, len = layout.length; i < len; i++) { l = layout[i]; this.store[l] = { "layout": l, "fn": fn }; } return; } return this.store[layout] = { "layout": layout, "fn": fn }; } generate(page, posts, ctx) { var layout; layout = page["layout"] || "page"; if (layout in this.store) { return this.store[layout]["fn"](page, posts, ctx); } return page; } }; }).call(this);