satelito

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

commit a17eb5bee2cf5e2766ce5a47c4d152612ec85114
parent 5129c930495cfe19f2de9ab21d79689ab5ac4624
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 11 Oct 2021 22:24:12 -0400

Add the collection functionality

Diffstat:
Msatelito/list.lua | 18++++++++++++++++++
Msatelito/site.lua | 3++-
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/satelito/list.lua b/satelito/list.lua @@ -3,8 +3,11 @@ local list = {} -- local dirtree = require 'satelito.dirtree' local file = require 'satelito.file' +local lfs = require 'lfs' -- luafilesystem local lume = require 'satelito.lib.lume.lume' +local inspect = require 'inspect' + -- Children function list.get_children(children_list, sitemap, asc) local children = {} @@ -29,6 +32,21 @@ function list.get_children(children_list, sitemap, asc) return children end +function list.get_collection(collection, sitemap, asc) + if collection and type(collection) == 'table' then + local collection_list = {} + local contentdir = lfs.currentdir()..'/'..sitemap[1].paths.content + + for i = 1, #collection do + collection_list[#collection_list+1] = file.get_collection(contentdir..collection[i], contentdir) + end + + return list.get_children(lume.concat(table.unpack(collection_list)), sitemap, asc) + end + + return +end + -- Archives function list.get_archives(contentdir) local archives_table = {} diff --git a/satelito/site.lua b/satelito/site.lua @@ -34,8 +34,9 @@ function site.make(sitemap, templates, export, timestart) local html, html_path local feed_xml, feed_xml_path - sitemap[i].root = sitemap + --sitemap[i].root = sitemap sitemap[i].children = list.get_children(sitemap[i].list, sitemap, sitemap[i].asc) + sitemap[i].collection = list.get_collection(sitemap[i].collection, sitemap, sitemap[i].asc) -- Make the page html, html_path = page.make(sitemap[i], templates)