fix(Responders): Don't assume templates are HTML XML feeds will be necessary for Atom or RSS feeds
Alan Pearce alan@alanpearce.eu
Sat, 08 Jul 2017 22:04:03 +0200
1 files changed, 7 insertions(+), 7 deletions(-)
jump to
M src/responders.js → src/responders.js
@@ -14,16 +14,16 @@ day: "numeric" }); const getTemplate = name => - fs.readFileSync(`${__dirname}/templates/${name}.html`, "utf8"); + fs.readFileSync(`${__dirname}/templates/${name}`, "utf8"); function getTemplateIndent(re, template) { return re.exec(getTemplate(template))[1].length; } const findMain = /^(\s+)<main/m; -const baseIndentLevel = getTemplateIndent(findMain, "layout"); +const baseIndentLevel = getTemplateIndent(findMain, "layout.html"); const findPostContent = /^(\s+)<div class="e-content/m; const postIndentLevel = - baseIndentLevel + getTemplateIndent(findPostContent, "post"); + baseIndentLevel + getTemplateIndent(findPostContent, "post.html"); function indentForTemplate(text, indentLevel) { return indent(text, indentLevel).slice(indentLevel).replace(/\n+$/, ""); @@ -34,10 +34,10 @@ return indentForTemplate(getTemplate(template), indentLevel); } const templates = { - layout: templateReader("layout"), - home: templateReader("home", baseIndentLevel), - post: templateReader("post", baseIndentLevel), - list: templateReader("list", baseIndentLevel) + layout: templateReader("layout.html"), + home: templateReader("home.html", baseIndentLevel), + post: templateReader("post.html", baseIndentLevel), + list: templateReader("list.html", baseIndentLevel) }; function title(siteTitle, pageTitle) {