commit 237fd9027395accb6180d8cec36382cc3feb6164
parent 87ddb5eed0912d68901c68be4d60341fb39efd32
Author: Hugo Soucy <hugo.soucy@toumoro.com>
Date: Mon, 10 Feb 2020 21:32:43 -0500
Add the current page mecanism
Diffstat:
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/ferron/page.lua b/ferron/page.lua
@@ -6,6 +6,7 @@ local pagemeta = {
end
}
+local inspect = require 'inspect'
local json = require 'dkjson'
local markdown = require 'discount'
local fl = require 'ferron.utilities.file-utils'
@@ -82,6 +83,20 @@ function page.render(page, sitedata)
local shortlinks_db
local shortlinks_tb
+ -- If in among navigation location values the permalink exists
+ -- Then set current parameter to true
+ -- Else set it to false
+ tb.each(
+ function(i)
+ if i.location == metaTable.permalink then
+ i.current = true
+ else
+ i.current = false
+ end
+ end,
+ metaTable.navigation
+ )
+
-- Populate Ferron.site.pagestable{}
if fl.isNotIndex(page) then
setpagetable(metaTable, pathRel)
@@ -131,16 +146,16 @@ function page.makepages(sitedata)
local indexpages = tb.filter(fl.isIndex, sitedata.nodes)
-- Render single pages
- tb.each(function(p) page.render(p, sitedata) end, singlepages)
+ tb.each(function(p) page.render(p, sitedata) end, singlepages)
-- Render index pages
- tb.each(function(p) page.render(p, sitedata) end, indexpages)
+ tb.each(function(p) page.render(p, sitedata) end, indexpages)
print('==========')
print('ยง ' .. tb.length(Ferron.site.pagestable) .. ' HTML pages have been created.')
print('==========')
- return
+ return --print(inspect(Ferron.site))
end
return setmetatable(page, pagemeta)