satelito

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

commit 287de2db6f12c3bd0bec4bace247a62eeb331f1a
parent e91a3fba1e0e8a38d9a2b9ccf3ea75abebf21a28
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sun, 10 Oct 2021 09:28:23 -0400

Add th e sitemapxml module

Diffstat:
Msatelito-dev-2.rockspec | 1+
Msatelito/init.lua | 9+++++++--
Asatelito/sitemapxml.lua | 16++++++++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/satelito-dev-2.rockspec b/satelito-dev-2.rockspec @@ -31,6 +31,7 @@ build = { ["satelito.model"] = "satelito/model.lua", ["satelito.page"] = "satelito/page.lua", ["satelito.site"] = "satelito/site.lua", + ["satelito.sitemapxml"] = "satelito/sitemapxml.lua", ["satelito.template"] = "satelito/template.lua", ["satelito.lib.lume.lume"] = "satelito/lib/lume/lume.lua", ["satelito.lib.lume.test.test"] = "satelito/lib/lume/test/test.lua", diff --git a/satelito/init.lua b/satelito/init.lua @@ -8,6 +8,7 @@ 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 @@ -121,7 +122,6 @@ if args['pipe'] then templates = lume.array(dirtree.get(lfs.currentdir() .. '/' .. config.paths.templates)) print('=> Making the web site ...') - return site.make(sitemap, templates, args['export'], timestart) end @@ -161,8 +161,13 @@ if args['make'] then print('=> Fetching the templates ...') templates = lume.array(dirtree.get(lfs.currentdir() .. '/' .. config.paths.templates)) - print('=> Making the web site ...') + if config.sitemapxml and args['export'] then + print('=> Making the sitemap.xml file ...') + local sitemapxml_xml, sitemapxml_xml_path = sitemapxml.make(sitemap, templates, config.paths.public_html) + file.export(sitemapxml_xml_path, sitemapxml_xml) + end + print('=> Making the web site ...') return site.make(sitemap, templates, args['export'], timestart) else print('There is no "config.lua" here.') diff --git a/satelito/sitemapxml.lua b/satelito/sitemapxml.lua @@ -0,0 +1,16 @@ +-- @module sitemapxml +local sitemapxml = {} +-- +local etlua = require 'etlua' +local file = require 'satelito.file' +local template = require 'satelito.template' + +function sitemapxml.make(sitemap, templates, destination) + local _sitemapxml = etlua.compile(file.read(template.find(templates, 'sitemap.xml'))) + local sitemapxml_xml = _sitemapxml({sitemap = sitemap}) + local sitemapxml_xml_path = destination..'sitemap.xml' + + return sitemapxml_xml, sitemapxml_xml_path +end + +return sitemapxml