sitegen = require "sitegen" lfs = require "lfs" rootname = (str) -> result = string.gsub str, "%..+", "" result split = (str, delimiter="/") -> [capture for capture in string.gmatch str, "[^#{delimiter}]+"] last = (list) -> list[#list] join = (first, last, delimiter="/") -> table.concat {first, last}, delimiter target = (path, prefix) -> join prefix, rootname(last(split path)) posts = (path=".") -> files = [file for file in lfs.dir path when file != "." and file != ".."] {join(path, file), target(file, "/posts") for _, file in ipairs files} sitegen.create => @title = "Hello World" @app_name = "stasis" @version = "0.2.12" add "index.md" add path, target: target for path, target in pairs posts "docs" css = require("sitegen.tools").system_command "cat < %s > %s", "css" build css, "index.css"