satelito

Static [web] site (or page) generator (ssg) made with Lua script.
git clone git://soucy.cc/satelito.git
Log | Files | Refs | README

commit 3fa6c3318a06541ef06e97e7e5df23fb5c3e6bf7
parent 41be4f0043d05a9e4ed650a6f816c1cf8e180464
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sun, 27 Feb 2022 20:38:00 -0500

Change the pagination function to do better slice

Diffstat:
Msatelito/list.lua | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/satelito/list.lua b/satelito/list.lua @@ -7,18 +7,25 @@ local lfs = require 'lfs' -- luafilesystem local lume = require 'satelito.lib.lume.lume' -- Pagination -function list.set_pagination(page_list, len) - local sliced_list = {} - local i = 1 +function list.set_pagination(pagelist, len) + local slicedlist = {} + local i = 1 - while(i < #page_list) do - local j = i + while(i < #pagelist) do + local j - i = i + (len-1) - sliced_list[#sliced_list+1] = lume.slice(page_list, j, i) - end + if i == 1 then + j = 1 + i = i + (len-1) + else + j = i + 1 + i = i + len + end + + slicedlist[#slicedlist+1] = lume.slice(pagelist, j, i) + end - return sliced_list + return slicedlist end -- Children