Fix dates on posts

This commit is contained in:
2025-06-16 20:18:05 -07:00
parent 91ca5c2f3f
commit 1b6cf0d89b
3 changed files with 25 additions and 24 deletions

View File

@@ -56,9 +56,7 @@ format_date = (str) -> date(str)\fmt "%b %d, %Y"
strip_date = (filename) ->
filename\gsub "#{escape_patt(extract_date(filename) .. "-")}/?", ""
publish_date = (path using extract_date, format_date) ->
date = extract_date path
date, format_date date
publish_date = (dt using format_date) -> { pretty: format_date(dt), iso: dt }
target = (path, prefix=".") ->
filename = rootname last common.split path, "/"
@@ -98,7 +96,7 @@ sitegen.create =>
md = @site\get_renderer "sitegen.renderers.markdown"
return for post in *posts
{:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta
{:title, :blurb, :id, :publish_date} = post.meta
url = rootname post\url_for!
if blurb
@@ -107,30 +105,34 @@ sitegen.create =>
section {
h3 { a { title or titleize_slug(id), href: url }}
time { pretty, datetime: iso }
time { publish_date.pretty, datetime: publish_date.iso }
"", blurb, a { "Read post →", class: "read-post-link", href: url }
}
add_all = (files) ->
add path, {
target: target path, "/posts"
template: "post"
is_a: "post"
publish_date: { publish_date path }
id: extract_id path
} for path in *files
for path in *files
add path, {
target: target path, "/posts"
template: "post"
is_a: "post"
publish_date: publish_date extract_date path
id: extract_id path
}
add "index.html", title: "Catalin Mititiuc"
add "blog.html", title: "Posts", target: "posts/index", template: "blog"
add "example.moon.md",
template: "post"
title: "MoonScript Example"
publish_date: format_date date true
publish_date: publish_date date true
add "code.md",
template: "post"
title: "Code Syntax Highlight Samples"
publish_date: format_date date true
-- add_all files_from "docs"
publish_date: publish_date date true
add_all files_from "docs"
copy "app.css"
copy "pygments.css"