ferron

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

commit b23b62a0f61e0d52eb8051d2d91f218bcaddce87
parent 9e0ae21b2a6e16db220d4549ba9110827f58d687
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 15 Jan 2018 18:23:24 -0500

Start to build the archive mecanism

Diffstat:
Mfunctions/make-lists-of-pages.lua | 29+++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua @@ -23,6 +23,7 @@ local function makelistsofpages() local listindex_section = path.dirname(listindex):match("^.+/(.+)$") local listindex_metadatas = json.decode(fileutils.pullfilecontent(listindex_noextension .. ".json")) local listindex_metadatas_mt = setmetatable({}, { __index = listindex_metadatas }) + local listindex_length = listindex_metadatas_mt.length ~= nil and listindex_metadatas_mt.length or nil print("ยง Make an index page for the `" .. listindex_section .. "` section:") @@ -35,11 +36,31 @@ local function makelistsofpages() -- Set a table for the list of entries listindex_metadatas_mt["entries"] = {} - for k, v in tableutils.sortdescendingpairs(Ferron.site.pagestable) do - local date, datetime, section, relpath = k:match("(.-)|(.-)|(.-)|(.-)$") + local pagecounter = listindex_length ~= nil and 0 or nil - if section == listindex_section or relpath:match("%/"..listindex_section.."%/") then - table.insert(listindex_metadatas_mt["entries"], v) + if pagecounter ~= nil then + for k, v in tableutils.sortdescendingpairs(Ferron.site.pagestable) do + local date, datetime, section, relpath = k:match("(.-)|(.-)|(.-)|(.-)$") + + if section == listindex_section or relpath:match("%/"..listindex_section.."%/") then + if pagecounter < listindex_length then + table.insert(listindex_metadatas_mt["entries"], v) + + pagecounter = pagecounter + 1 + end + + print(section) + end + end + else + for k, v in tableutils.sortdescendingpairs(Ferron.site.pagestable) do + local date, datetime, section, relpath = k:match("(.-)|(.-)|(.-)|(.-)$") + + if section == listindex_section or relpath:match("%/"..listindex_section.."%/") then + table.insert(listindex_metadatas_mt["entries"], v) + + print(section) + end end end