5 changed files with 19 additions and 21 deletions
@ -1,16 +1,9 @@
@@ -1,16 +1,9 @@
|
||||
var LRU = require("lru-cache"), |
||||
marked = require("marked"), |
||||
fs = require("fs"); |
||||
var marked = require("marked"); |
||||
var 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); |
||||
|
||||
module.exports.build = id => { |
||||
if (CACHE.has(id)) return CACHE.get(id); |
||||
var content = "This is page " + id; |
||||
CACHE.set(id, content); |
||||
return content; |
||||
}; |
||||
module.exports.build = note => buildHTML(note.title, marked(note.text)); |
||||
|
||||
Loading…
Reference in new issue