ferron

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

commit d881dfa806cc63594b109f5d05edd3bbaec6b443
parent 1a71f8753c23ab7fb277f83f8e510011aa093b58
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Tue, 22 Jan 2019 11:37:35 -0500

Add a basic navigation mecanism

Diffstat:
Mferron/site.lua | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/ferron/site.lua b/ferron/site.lua @@ -77,6 +77,30 @@ function site.setsite(name) return true end +function site.makenavigation() + local navigation = {} + + for file in lfs.dir(site.content) do + if file ~= "." and file ~= ".." then + local filepath = site.content .. "/" .. file + local fileconf = fileutils.isMarkdown(filepath) and fileutils.getpageconf(filepath) or fileutils.getpageconf(filepath .. "/index.md") + local filerelpath = fileutils.isMarkdown(filepath) and fileutils.getplainname(filepath) .. ".html" or fileutils.getbasename(filepath) + + if fileconf and fileconf.navigationlabel and fileconf.navigation ~= false then + table.insert(navigation, {label = fileconf.navigationlabel, location = site.config.baseurl .. "/" .. filerelpath}) + elseif fileconf and fileconf.navigation ~= false then + table.insert(navigation, {label = fileconf.title, location = site.config.baseurl .. "/" .. filerelpath}) + end + end + end + + print(inspect(navigation)) + + os.exit('1') + + return navigation +end + function site.makesite() local newsite = { domain = nil,