Static site generator made with Lua script.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

-- @module page
local page = {}
local etlua = require 'etlua'
local lume = require 'satelito.lib.lume.lume'
local file = require 'satelito.file'
local template = require 'satelito.template'
--- Build a page from markdown/lua to HTML
-- @name page.make
-- @param filepath a pathname to a markdown file
-- @return a string that is an HTML code block
-- @return a string that is a filepath
function page.make(filemeta, exportpath)
-- Compile different parts of the page
local head = etlua.compile(, filemeta.head)))
local navigation = etlua.compile(, filemeta.navigation)))
local post = etlua.compile(, filemeta.template)))
local footer = etlua.compile(, filemeta.footer)))
local layout = etlua.compile(, filemeta.layout)))
-- Then put them all together
local html = layout(
{post = post(lume.extend({}, filemeta))},
{head = head(lume.extend({}, filemeta))},
{navigation = navigation(lume.extend({}, filemeta))},
{footer = footer(lume.extend({}, filemeta))}
-- Get the target location of the page
local html_path = exportpath ~= nil and exportpath or filemeta.exportlink
return html, html_path
return page