This commit is contained in:
Catalin Constantin Mititiuc 2025-05-21 20:58:11 -07:00
parent e878441819
commit 9eb06e2789

View File

@ -43,16 +43,22 @@ rootname = (str) ->
result = string.gsub str, "%..+", ""
result
last = (list) -> list[#list]
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
target = (path, prefix) -> join prefix, rootname(last(common.split path, "/"))
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
last = (list) -> list[#list]
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
target = (path, prefix=".") ->
a = rootname(last(common.split path, "/"))
b = a\gsub "#{escape_patt(extract_date(a) .. "-")}/?", ""
p b
b
Path.join prefix, a\gsub("#{escape_patt(extract_date(a) .. "-")}/?", "")
h = (word) -> word\sub(1, 1)\upper!
t = (word) -> word\sub(2, -1)\lower!
titleize = (word) -> h(word), t(word)
@ -105,9 +111,7 @@ documents = (path=".") ->
{join(path, file), target(file, "/posts") for file in *files}
clean = (target) ->
dirty = extract_date target
escaped = dirty\gsub("%-", "%%-") .. "%-"
target\gsub(escaped, "")
target\gsub "#{escape_patt(extract_date(target) .. "-")}/?", ""
sitegen.create =>
@site_title = "WebDevCat.me"
@ -116,11 +120,11 @@ sitegen.create =>
@list_posts = list_posts @, template
add_all = (name, files) ->
for path, target in pairs files
for path, _ in pairs files
id = extract_id path
add path,
target: clean(target)
target: clean(target(path, "/posts"))
template: name
is_a: name
publish_date: publish_date path