satelito

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

commit 5bb021161d3647fc60ee980c83f1f3521a4b7ca7
parent d38feaae1dd5daf65c05ac0aae6d830f9780cb58
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Tue, 30 Mar 2021 08:51:55 -0400

Use file model instead of config file

Diffstat:
Msatelito/page.lua | 24+++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/satelito/page.lua b/satelito/page.lua @@ -4,51 +4,49 @@ local markdown = require 'discount' -- lua-discount local lume = require 'satelito.lib.lume.lume' local file = require 'satelito.file' local list = require 'satelito.list' -local model = require 'satelito.model' local site = require 'satelito.site' local template = require 'satelito.template' +local inspect = require 'inspect' --- Build a page from markdown/lua to HTML -- @name page.build -- @param filepath a pathname to a markdown file -- @return a string that is an HTML code block -function page.build(filepath) +function page.build(filepath, filemeta) if file.is_markdown(filepath) then - local config = assert(site.set_config(filepath), "Sorry, the site configuration can't be set") -- Post local post_content = { content = assert(markdown(file.read(filepath))) } - local post_parameters = assert(model.get(filepath)) + local post_meta = filemeta local post_children = { children = (file.is_index(filepath) and list.build(filepath)) } - local post_template = assert(template.set_post(post_parameters, filepath)) + local post_template = assert(template.set_post(post_meta, filepath)) local post_html if post_children then - post_html = post_template(lume.extend({}, post_content, post_parameters, post_children)) + post_html = post_template(lume.extend({}, post_content, post_meta, post_children)) else - post_html = post_template(lume.extend({}, post_content, post_parameters)) + post_html = post_template(lume.extend({}, post_content, post_meta)) end -- Head local head_template = assert(template.set_head(filepath)) - local head_html = head_template(lume.extend({}, post_parameters)) + local head_html = head_template(lume.extend({}, post_meta)) -- Navigation local navigation_template = assert(template.set_navigation(filepath)) - local navigation_html = navigation_template(lume.extend({}, post_parameters)) + local navigation_html = navigation_template(lume.extend({}, post_meta)) -- Page - local page_layout = assert(template.set_layout(post_parameters, filepath)) + local page_layout = assert(template.set_layout(post_meta, filepath)) local page_html = page_layout( lume.extend({}, - config, - post_parameters, + post_meta, {head = head_html}, {navigation = navigation_html}, {post = post_html} ) ) local page_html_path = assert( - site.get_root(filepath) .. '/' .. config.paths.public_html .. post_parameters.relpath:match('(.+)%..*') .. '.html' + site.get_root(filepath) .. '/' .. post_meta.paths.public_html .. post_meta.relpath:match('(.+)%..*') .. '.html' ) return page_html, page_html_path