--
--
-- — We thought we wanted a static website generator. It turns out what we really wanted was Phoenix, with an option to convert markdown to HTML. Here is our implementation of a solution, using our very own, recently-released, Pandoc Hex package!
--
-- Read post →
--
--
date = require "date"
-- date!
-- return {
-- format: "markdown"
-- title: "My Site's Title"
-- {
-- title: "The First Post"
-- date: date 2011, 11, 26
-- require("moon").p tostring(date(2011, 11, 26))
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
html ->
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 page.site.pages when p.meta.template == "blog"]
-- require("moon").p [p.meta for _, p in pairs page.site.pages]
table.sort posts, (a, b) -> a.src > b.src
[tag["section"] {
tag["h3"] { tag["a"] { href: p.tgt .. ".html", p.title }}
tag["time"] { publish_date p.src }
"—" .. if p.blurb then " #{p.blurb}" else ""
tag["a"] { class: "read-post-link", href: p.tgt .. ".html", "Read post →"}
} for _, p in ipairs posts]