satelito

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

commit dcc725580059099a184d3c0447943f0ee524e388
parent 34b9b099447d9b349e2583fa7579b658482e4971
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Fri,  9 Apr 2021 14:36:20 -0400

Refactor the feed module

Diffstat:
Msatelito/feed.lua | 26++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/satelito/feed.lua b/satelito/feed.lua @@ -1,33 +1,19 @@ -- @module feed local feed = {} -- +local etlua = require 'etlua' local lume = require 'satelito.lib.lume.lume' local file = require 'satelito.file' -local list = require 'satelito.list' -local site = require 'satelito.site' local template = require 'satelito.template' +local inspect = require 'inspect' -function feed.build(filepath, filemeta) - local feed_meta = filemeta - local relpath = assert(file.get_relpath(filepath, site.get_root(filepath) .. '/' .. feed_meta.paths.content)) - local feed_entries = { children = assert(file.is_index(filepath) and list.build(filepath) or {}) } - local feed_template = assert(template.set_feed(filepath)) - local feed_xml = feed_template(lume.extend({}, feed_meta, feed_entries)) - local feed_xml_path = assert( - site.get_root(filepath) - .. '/' - .. feed_meta.paths.public_html - .. relpath:match('(.+)%..*') .. '.xml' - ) +function feed.make(filemeta, templates) + local _feed = etlua.compile(file.read(template.find(templates, filemeta.feed))) + local feed_xml = _feed(lume.extend({}, filemeta)) + local feed_xml_path = filemeta.exportlink:match('(.+)%..*')..'.xml' return feed_xml, feed_xml_path end -function feed.export(feedpath, feedxml) - file.mkdir(file.get_dirname(feedpath)) - - return file.write(feedpath, feedxml) -end - return feed