satelito

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

commit 0e26ff7f1847a5c1c442b9446c4fbf860df70bcb
parent 14bc58714f03dba752a32e6353067ad89bd84d7a
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Wed, 30 Nov 2022 14:40:05 -0500

Move the sitmapxml into the site.lua file

Diffstat:
Msatelito/init.lua | 19++-----------------
Msatelito/site.lua | 20+++++++++++++++++++-
2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/satelito/init.lua b/satelito/init.lua @@ -8,14 +8,12 @@ local lume = require 'satelito.lib.lume.lume' local model = require 'satelito.model' local dirtree = require 'satelito.dirtree' local file = require 'satelito.file' -local sitemapxml = require 'satelito.sitemapxml' local site = require 'satelito.site' -- local init local pipe local make local exec -local test local parser = argparse() :name 'satelito' @@ -35,12 +33,10 @@ make:flag('-e --export', 'Export the outputed HTML in the *config.paths.public_h exec = parser:command('exec', 'Execute a script frome the bin directory') exec:argument 'bin name' -test = parser:command('test', '') - args = parser:parse() -- Started -print('=> Satelito is on ...') +print('=> Satelito is here ...') ------------- -- GLOBALS -- @@ -170,16 +166,5 @@ if args['make'] then -- Sort before make the website table.sort(lume.unique(sitedata), function(a, b) return a.idorder > b.idorder end) - site.make(sitedata, args['export']) - - -- Make and export the sitemap.xml - if config.sitemapxml and args['export'] then - local sitemapxml_xml, sitemapxml_xml_path = sitemapxml.make( - sitedata, templates, config.paths.public_html - ) - - file.export(sitemapxml_xml_path, sitemapxml_xml) - end - - return + return site.make(sitedata, args['export']) end diff --git a/satelito/site.lua b/satelito/site.lua @@ -10,6 +10,7 @@ local file = require 'satelito.file' local list = require 'satelito.list' local lume = require 'satelito.lib.lume.lume' local page = require 'satelito.page' +local sitemapxml = require 'satelito.sitemapxml' --- From a filepath get the closest 'config.lua' by climbing the -- directory tree @@ -32,9 +33,13 @@ end -- Make the site (from the sitedata) function site.make(sitedata) local duration + local config = _G.Satelito.config + local contentdir = _G.Satelito.contentdir local export = _G.Satelito.args['export'] + local make = _G.Satelito.args['make'] + local publicdir = _G.Satelito.publicdir + local templates = _G.Satelito.templates local timestart = _G.Satelito.timestart - local contentdir = _G.Satelito.contentdir for i = 1, #sitedata do local html, html_path @@ -43,10 +48,14 @@ function site.make(sitedata) sitedata[i].index = i + -- Lists + -- Subpages from the actual index page if sitedata[i].list ~= false and file.is_index(sitedata[i].path) then sitedata[i].children = list.get_children(sitedata[i].list, sitedata, sitedata[i].asc) end + -- Collections + -- Group of pages from specific relpaths if sitedata[i].collection and sitedata[i].collection_list then sitedata[i].collection = list.get_children(sitedata[i].collection_list, sitedata, sitedata[i].asc) end @@ -128,6 +137,15 @@ function site.make(sitedata) end end + -- Make and export the sitemap.xml + if config.sitemapxml and make and export then + local sitemapxml_xml, sitemapxml_xml_path = sitemapxml.make( + sitedata, templates, publicdir + ) + + file.export(sitemapxml_xml_path, sitemapxml_xml) + end + duration = os.difftime(os.time(), timestart) > 0 and 'in approximately '..os.difftime(os.time(), timestart)..' second(s).' or 'in less than 1 second.'