satelito

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

site.lua (556B)


      1 -- @module site
      2 local site = {}
      3 --
      4 local lfs = require 'lfs'
      5 
      6 --- From a filepath get the closest 'config.lua' by climbing the
      7 -- directory tree
      8 -- Recursive function
      9 function site.get_config(filepath)
     10   assert(filepath and filepath ~= '', 'The filepath parameter is missing or empty.')
     11 
     12   local dir = filepath:match("(.*/)")
     13   local dir_parent = string.sub(dir, 1, -2):match("(.*/)")
     14 
     15   for entry in lfs.dir(dir) do
     16     if entry and entry == 'config.lua' then
     17       return dir .. entry
     18     end
     19   end
     20 
     21   return site.get_config(dir_parent)
     22 end
     23 
     24 return site