ferron

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

commit 7db6a705b178cff6cad8a580fdce97d485a428ce
parent ce9c2153e4b63e2c6181990323456a67424e77f4
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Thu,  8 Feb 2018 11:06:55 -0500

Add a shortlink value to page.

Diffstat:
Mferron/page.lua | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ferron/page.lua b/ferron/page.lua @@ -9,6 +9,8 @@ local page = {} function page.makepage() local contentpath = Ferron.site.path .. Ferron.site.siteconfig.paths.content + local shortlinks_db = path.isfile(Ferron.site.path .. Ferron.site.siteconfig.paths.data .. "/shortlinks.json") + local shortlinks_tb = (shortlinks_db ~= false and json.decode(fileutils.pullfilecontent(shortlinks_db)) or nil) -- Loop in the content directory print("- Looking for markdown in " .. contentpath .. " ...") @@ -38,6 +40,11 @@ function page.makepage() page_conf_mt.section = nil page_conf_mt["site"] = Ferron.site.siteconfig + -- If exists set the shortlink + if shortlinks_tb ~= nil and shortlinks_db ~= nil then + page_conf.shortlink = (shortlinks_tb[page_conf_mt.rellink] ~= nil and shortlinks_tb[page_conf_mt.rellink] or nil) + end + Ferron.site.pagestable[page_key] = page_conf_mt if path.isdir(page_htmlpath) == false then @@ -59,7 +66,7 @@ function page.makepage() end -- Update the JSON file data - fileutils.pushfilecontent(page_noextension .. ".json", json.encode(page_conf, {indent = true, keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","section","template","title","updated"}})) + fileutils.pushfilecontent(page_noextension .. ".json", json.encode(page_conf, {indent = true, keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","section","shortlink","template","title","updated"}})) end end, {