ferron

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

commit f62812d34d9d58fed254734df029c133996050d8
parent b88e3f6d69ac657c68686cdbc18268ab2283be06
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Tue, 28 Nov 2017 15:18:44 -0500

Remove the content property from the json files.

Put it in a metatable instead.

Diffstat:
Mfunctions/make-pages.lua | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/functions/make-pages.lua b/functions/make-pages.lua @@ -25,22 +25,23 @@ local function makepages() local md_html = md_pathhtml .. "/" .. md_plainname .. ".html" local md_section = md_relpath:match("/(%a-)/") local md_metadatas = json.decode(fileutils.pullfilecontent(md_noextension .. ".json")) + local md_metadatas_mt = setmetatable({}, { __index = md_metadatas }) local md_updated = os.date("%Y-%m-%dT%H:%M:%S", attr.modification) local md_id = "tag:" .. Ferron.site.config.SITE.DOMAINNAME .. "," .. md_metadatas.date .. ":" .. string.sub(md_metadatas.date, 0, 4) .. "/" .. string.sub(md_metadatas.date, 6, 7) .. "/" .. md_plainname local md_key = md_metadatas.date .. "|" .. md_metadatas.datetime .. "|" .. (md_section ~= nil and md_section or "root") .. "|" .. md_relpath local md_table = {} -- Convert the markdown file to HTML - md_metadatas.content = markdown(fileutils.pullfilecontent(md)) + md_metadatas_mt.content = markdown(fileutils.pullfilecontent(md)) md_metadatas.section = md_section md_metadatas.updated = md_updated md_metadatas.id = md_id md_metadatas.permalink = Ferron.site.config.SITE.BASEURL .. (md_plainname ~= "index" and md_relpath .. ".html" or "") - Ferron.site.pagestable[md_key] = md_metadatas + Ferron.site.pagestable[md_key] = md_metadatas_mt - md_table = md_metadatas + md_table = md_metadatas_mt md_table["SITE"] = Ferron.site.config.SITE if path.isdir(md_pathhtml) == false then @@ -65,6 +66,7 @@ local function makepages() -- Update the JSON file data md_metadatas["SITE"] = nil + fileutils.pushfilecontent(md_noextension .. ".json", json.encode(md_metadatas, {indent = true})) end end