28 lines
809 B
Plaintext
28 lines
809 B
Plaintext
date = require "date"
|
|
path = require "sitegen.path"
|
|
moon = require("moon")
|
|
common = require("sitegen.common")
|
|
|
|
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
|
|
|
|
posts = [{
|
|
id: p.meta.id
|
|
tgt: p.meta.target
|
|
src: p.source
|
|
title: p.meta.title or p.meta.id
|
|
blurb: p.meta.blurb
|
|
} for _, p in pairs site.pages when p.meta.template == "blog"]
|
|
|
|
table.sort posts, (a, b) -> a.src > b.src
|
|
|
|
html ->
|
|
[tag["section"] {
|
|
tag["h3"] { tag["a"] { href: p.tgt .. ".html", p.title }}
|
|
tag["time"] { publish_date p.src }
|
|
{"—", if p.blurb then text(p.blurb)}
|
|
tag["a"] { class: "read-post-link", href: p.tgt .. ".html", "Read post →"}
|
|
} for _, p in ipairs posts]
|
|
|