miti.sh/site.moon

34 lines
908 B
Plaintext

sitegen = require "sitegen"
lfs = require "lfs"
tools = require "sitegen.tools"
site = require "sitegen.site"
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}
site!
site.config.out_dir = "html/"
css = tools.system_command "cat < %s > %s", "css"
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"
build(css, "app.css")