satelito

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

page.lua (1175B)


      1 -- @module page
      2 local page = {}
      3 --
      4 local etlua = require 'etlua'
      5 local lume = require 'satelito.lib.lume.lume'
      6 local file = require 'satelito.file'
      7 local template = require 'satelito.template'
      8 
      9 --- Build a page from markdown/lua to HTML
     10 -- @name page.build
     11 -- @param filepath a pathname to a markdown file
     12 -- @return a string that is an HTML code block
     13 
     14 function page.make(filemeta, templates)
     15   local post = etlua.compile(file.read(template.find(templates, filemeta.template)))
     16   local head = etlua.compile(file.read(template.find(templates, filemeta.head)))
     17   local navigation = etlua.compile(file.read(template.find(templates, filemeta.nav)))
     18   local footer = etlua.compile(file.read(template.find(templates, filemeta.footer)))
     19   local layout = etlua.compile(file.read(template.find(templates, filemeta.layout)))
     20   local html = layout(
     21     lume.extend({},
     22       filemeta,
     23       {post = post(lume.extend({}, filemeta))},
     24       {head = head(lume.extend({}, filemeta))},
     25       {navigation = navigation(lume.extend({}, filemeta))},
     26       {footer = footer(lume.extend({}, filemeta))}
     27     )
     28   )
     29   local html_path = filemeta.exportlink
     30 
     31   return html, html_path
     32 end
     33 
     34 return page