5 changed files with 19 additions and 21 deletions
@ -1,16 +1,9 @@ |
|||||||
var LRU = require("lru-cache"), |
var marked = require("marked"); |
||||||
marked = require("marked"), |
var fs = require("fs"); |
||||||
fs = require("fs"); |
|
||||||
|
|
||||||
var CACHE = new LRU(30); // create LRU cache of size 30
|
|
||||||
var template = fs.readFileSync("resources/template.html", "utf-8"); |
var template = fs.readFileSync("resources/template.html", "utf-8"); |
||||||
var buildHTML = (title, content) => template |
var buildHTML = (title, content) => template |
||||||
.replace("%TITLE%", title) |
.replace("%TITLE%", title) |
||||||
.replace("%CONTENT%", content); |
.replace("%CONTENT%", content); |
||||||
|
|
||||||
module.exports.build = id => { |
module.exports.build = note => buildHTML(note.title, marked(note.text)); |
||||||
if (CACHE.has(id)) return CACHE.get(id); |
|
||||||
var content = "This is page " + id; |
|
||||||
CACHE.set(id, content); |
|
||||||
return content; |
|
||||||
}; |
|
||||||
|
|||||||
Loading…
Reference in new issue