napkin/template/blog.lua

82 lines
2.6 KiB
Lua
Raw Normal View History

---@diagnostic disable:undefined-global
return function()
local user = {
handle = "@supercool",
name = "Super Cool",
biography =
"i am a super cool person, hello, welcome to my thing, uhhh, that thing where you write a thing and then you're like \"okay now what\" and write some more things because you can't think of anything else to write, and then you add some funny emojis like 🌙 🎂 🍋 okay anyway the point is i'm doing that thing where i just keep writing more and more stuff because i'm supposed to make it longer and more boring and not actually say anything",
posts = {
{
title = "Do not ever consume pizza.",
timestamp = os.time()
},
{
title = "Why I don't believe in aliens.",
timestamp = os.time() - 90000
},
{
title = "Pizza SUCKS, here's why.",
timestamp = os.time() - 90000 * 4,
pinned = true
}
},
}
return html {
head {
meta { charset = "UTF-8" },
meta { ["http-equiv"] = "X-UA-Compatible", content = "IE=edge" },
meta { name = "viewport", content = "width=device-width, initial-scale=1.0" },
title "Document",
link { href = "static/baseline.css", rel = "stylesheet" },
},
body {
h1(user.name),
p({
a { href = "/", "instance.com/" },
" ",
a { href = "/" .. user.handle, user.handle .. "/" }
}),
br(),
section({ class = "biography", user.biography }),
section(function(o)
o.class = "post-list pinned-list"
table.insert(o, h2("Pinned:"))
for _, post in ipairs(user.posts) do
if post.pinned then
table.insert(o, div {
class = "post",
h2("📌 " .. post.title),
p(os.date("%Y-%m-%d %H:%M:%S", post.timestamp))
})
end
end
end),
section(function(o)
o.class = "post-list"
table.insert(o, h2("Posts:"))
for _, post in ipairs(user.posts) do
table.insert(o, div {
class = "post",
h2(post.title),
p(os.date("%Y-%m-%d %H:%M:%S", post.timestamp))
})
end
end)
}
}
end