commit 8387cf072737d74bda2166f35aa1185c883451e6
parent 39aba9701db3493f079f1ffd7cdf28e27ba42edc
Author: Hugo Soucy <hugo@soucy.cc>
Date: Tue, 29 Nov 2022 20:23:41 -0500
Enhance collection and list with the pipe command
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/satelito/list.lua b/satelito/list.lua
@@ -3,8 +3,7 @@ local list = {}
--
local dirtree = require 'satelito.dirtree'
local file = require 'satelito.file'
-local inspect = require 'inspect'
-local lfs = require 'lfs' -- luafilesystem
+local model = require 'satelito.model'
local lume = require 'satelito.lib.lume.lume'
-- Pagination
@@ -30,15 +29,23 @@ function list.set_pagination(pagelist, len)
end
-- Get children contents
-function list.get_children(children_list, sitemap, asc)
+function list.get_children(children_list, sitedata, asc)
local children = {}
+ local relpaths = {}
+ local contentdir = _G.Satelito.contentdir
if children_list then
- for i = 1, #sitemap do
- local is_child = lume.find(children_list, sitemap[i].relpath)
+ for i = 1, #sitedata do
+ relpaths[#relpaths+1] = sitedata[i].relpath
+ end
+
+ for i = 1, #children_list do
+ local is_exists = lume.find(relpaths, children_list[i])
- if is_child then
- children[#children+1] = sitemap[i]
+ if is_exists then
+ children[#children+1] = sitedata[is_exists]
+ else
+ children[#children+1] = model.set(contentdir..children_list[i])
end
end