ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit d60fac8d93e5e392d35991a79d904c8a62075c8f
parent cd9284b7ddc01c0f9bcaec321af22f8a59655ac4
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Thu,  4 Oct 2018 12:01:11 -0400

Add a `list_template` local var.

Diffstat:
Mferron/list.lua | 29+++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/ferron/list.lua b/ferron/list.lua @@ -67,6 +67,7 @@ function list.makelist() local list_htmlpath = fileutils.sethtmlpath(fileutils.getrelpath(path.dirname(list))) local list_conf = json.decode(fileutils.pullfilecontent(fileutils.removeextension(list) .. ".json")) local list_conf_mt = setmetatable({}, { __index = list_conf }) + local list_template = templatespath .. "/" .. (list_conf.template ~= nil and list_conf.template or "default-index") .. ".mustache" print("ยง Make a list page for the `" .. fileutils.getrelpath(path.dirname(list)) .. "` subdirectory ...") @@ -94,30 +95,26 @@ function list.makelist() -- Move static files in the public HTML folder static.dispatch(list) - -- Build the HTML file + print("==========") + + -- Update the JSON file data fileutils.pushfilecontent( + fileutils.removeextension(list) .. ".json", + json.encode(list_conf, {indent = true, keyorder = Ferron.site.siteconfig.metaskeyorder}) + ) + + + -- Build and push the HTML page + htmldoc = fileutils.pushfilecontent( list_htmlpath .. "/" .. fileutils.getplainname(list) .. ".html", templateutils.processmustache( - fileutils.pullfilecontent(templatespath .. "/" .. (list_conf.template ~= nil and list_conf.template or "default-index") .. ".mustache"), + fileutils.pullfilecontent(list_template), templatespath .. "/partials", list_conf_mt ) ) - if not path.isfile(list_htmlpath .. "/" .. fileutils.getplainname(list) .. ".html") then - print(" !! " .. fileutils.getrelpath(fileutils.removeextension(list)) .. ".html - error!") - end - - print("==========") - - -- Update the JSON file data - list_conf["entries"] = nil - list_conf["site"] = nil - - fileutils.pushfilecontent( - fileutils.removeextension(list) .. ".json", - json.encode(list_conf, {indent = true, keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","template","title","updated"}}) - ) + return end, { delay = true; -- use snapshot of directory