70 lines
2.2 KiB
Plaintext
70 lines
2.2 KiB
Plaintext
sitegen = require "sitegen"
|
|
tools = require "sitegen.tools"
|
|
site = require "sitegen.site"
|
|
lfs = require "lfs"
|
|
|
|
date = require "date"
|
|
path = require "sitegen.path"
|
|
-- import slugify from "sitegen.common"
|
|
|
|
-- Change output dir to what Openresty prefers
|
|
site.config.out_dir = "html/"
|
|
|
|
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}
|
|
|
|
extract_id = (source) -> string.match path.filename(source), "%a[%w%-]+"
|
|
extract_date = (source) -> string.match path.filename(source), "%d+%-%d%d%-%d%d"
|
|
format_date = (str) -> date(str)\fmt "%b %d, %Y"
|
|
publish_date = (path) -> format_date extract_date path
|
|
|
|
-- monkey-patch sitegen to use pandoc for markdown conversion
|
|
os.execute "moonc -t \
|
|
/usr/local/openresty/luajit/share/lua/5.1/sitegen/renderers/ markdown.moon"
|
|
|
|
sitegen.create =>
|
|
@site_title = "WebDevCat.me · Catalin Mititiuc"
|
|
@app_name = "stasis"
|
|
@version = "0.2.12"
|
|
|
|
add "index.html"
|
|
add path, target: out, template: "blog", is_a: "post", post: {
|
|
publish_date: publish_date(path)
|
|
}, id: extract_id(path) for path, out in pairs posts "docs"
|
|
|
|
-- add "docs/2023-11-15-test-mix-task-file-modify.md",
|
|
-- target: "posts/2023-11-15-test-mix-task-file-modify.html"
|
|
-- template: "blog"
|
|
-- is_a: "post"
|
|
-- post: {
|
|
-- publish_date: publish_date "docs/2023-11-15-test-mix-task-file-modify.md"
|
|
-- }
|
|
-- id: extract_id "docs/2023-11-15-test-mix-task-file-modify.md"
|
|
|
|
copy "app.css"
|
|
|
|
-- filter "docs", (body) =>
|
|
-- require("moon").p body
|
|
|
|
-- filter "2023%-08%-03", (body) =>
|
|
-- table.concat { body, "<p>hey there</p>" }
|
|
--
|
|
-- body\gsub "<h1>.-</h1>", (header) ->
|
|
-- table.concat { body, "yoyoasdf" }
|
|
--
|
|
-- body\gsub "{.-}", (header) ->
|
|
-- require("moon").p header
|
|
-- table.concat { '</div>', header, '<div class="main">' }
|