ferron

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

commit 25e28db36dd323658d796a4121a58fd79dc76863
parent 69efdeffa3d5db652069de93f7474820523156c4
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Tue, 28 Nov 2017 16:04:25 -0500

Add a keyorder table for the json encode process.

Diffstat:
Mfunctions/make-lists-of-pages.lua | 4++--
Mfunctions/make-pages.lua | 11++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua @@ -44,7 +44,7 @@ local function makelistsofpages() fileutils.mkdir(listindex_pathhtml) end - dispatchnontextuals(listindex, listindex_section) + dispatchnontextuals(listindex, listindex_section) -- Build the HTML file fileutils.pushfilecontent( @@ -67,7 +67,7 @@ local function makelistsofpages() -- Update the JSON file data listindex_metadatas["entries"] = nil listindex_metadatas["SITE"] = nil - fileutils.pushfilecontent(listindex:match("(.+)%..*") .. ".json", json.encode(listindex_metadatas, {indent = true})) + fileutils.pushfilecontent(listindex:match("(.+)%..*") .. ".json", json.encode(listindex_metadatas, {indent = true,keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","section","template","title","updated"}})) end end end diff --git a/functions/make-pages.lua b/functions/make-pages.lua @@ -3,6 +3,7 @@ local json = require("dkjson") local markdown = require("markdown") local path = require("path") local fileutils = require("functions.file-utils") +local tableutils = require("functions.table-utils") local templateutils = require("functions.template-utils") local function makepages() @@ -29,9 +30,9 @@ local function makepages() 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 + -- And put it in a metatable md_metadatas_mt.content = markdown(fileutils.pullfilecontent(md)) md_metadatas.section = md_section @@ -41,8 +42,7 @@ local function makepages() Ferron.site.pagestable[md_key] = md_metadatas_mt - md_table = md_metadatas_mt - md_table["SITE"] = Ferron.site.config.SITE + md_metadatas_mt["SITE"] = Ferron.site.config.SITE if path.isdir(md_pathhtml) == false then fileutils.mkdir(md_pathhtml) @@ -54,7 +54,7 @@ local function makepages() templateutils.setmustache( fileutils.pullfilecontent(Ferron.site.path .. Ferron.site.config.SITE.PATHS.TEMPLATES .. "/" .. md_metadatas.template .. ".mustache"), Ferron.site.path .. Ferron.site.config.SITE.PATHS.TEMPLATES .. "/partials", - md_table + md_metadatas_mt ) ) @@ -65,7 +65,8 @@ local function makepages() end -- Update the JSON file data - fileutils.pushfilecontent(md_noextension .. ".json", json.encode(md_metadatas, {indent = true})) + md_metadatas.content = nil + fileutils.pushfilecontent(md_noextension .. ".json", json.encode(md_metadatas, {indent = true, keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","section","template","title","updated"}})) end end