page builder module started

This commit is contained in:
Christian Müller
2015-08-17 09:23:28 +02:00
parent 9ed2df2c8f
commit b2b383b941
9 changed files with 322 additions and 314 deletions
-1
View File
@@ -1 +0,0 @@
var f = () => console.log("hello world!");
+17
View File
@@ -0,0 +1,17 @@
var LRU = require("lru-cache"),
marked = require("marked"),
fs = require("fs");
var CACHE = new LRU(30); // create LRU cache of size 30
var template = fs.readFileSync("resources/template.html", "utf-8");
var buildHTML = (title, content) => template
.replace("%TITLE%", title)
.replace("%CONTENT%", content);
var apiPage = buildHTML("API", marked(fs.readFileSync("API.md", "utf-8")));
export var build = id => {
if (CACHE.has(id)) return CACHE.get(id);
var content = id == "api" ? apiPage : "This is page " + id;
CACHE.set(id, content);
return content;
};