Output blurb text as markup
This commit is contained in:
parent
f98c228b3c
commit
48d3f807c9
58
posts.moon
58
posts.moon
@ -1,55 +1,4 @@
|
|||||||
-- html ->
|
|
||||||
--
|
|
||||||
-- posts = [{
|
|
||||||
-- id: p.meta.id
|
|
||||||
-- target: p.meta.target
|
|
||||||
-- source: p.source
|
|
||||||
-- } for _, p in pairs site.pages when p.meta.template == "blog"]
|
|
||||||
--
|
|
||||||
-- require("moon").p posts
|
|
||||||
-- div { "this is a post" }
|
|
||||||
-- div { "this anoter post" }
|
|
||||||
|
|
||||||
-- date = require "date"
|
|
||||||
-- return {
|
|
||||||
-- format: "markdown"
|
|
||||||
-- title: "My Site's Title"
|
|
||||||
-- {
|
|
||||||
-- title: "The First Post"
|
|
||||||
-- date: date 2011, 11, 26
|
|
||||||
-- link: "/my-post"
|
|
||||||
-- description: [[
|
|
||||||
-- The things I did.
|
|
||||||
--
|
|
||||||
-- * ordered pizza
|
|
||||||
-- * ate it
|
|
||||||
-- ]]
|
|
||||||
-- }
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- <section>
|
|
||||||
-- <h3>
|
|
||||||
-- <a href="/posts/publish-markdown-documents-as-static-web-pages-with-pandoc-and-phoenix">
|
|
||||||
-- Publish Markdown Documents As Static Web Pages with Pandoc and Phoenix
|
|
||||||
-- </a>
|
|
||||||
-- </h3>
|
|
||||||
--
|
|
||||||
-- <time datetime="2025-01-18">Jan 18, 2025</time>
|
|
||||||
-- — 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!
|
|
||||||
-- <a href="/posts/publish-markdown-documents-as-static-web-pages-with-pandoc-and-phoenix" class="read-post-link">
|
|
||||||
-- Read post →
|
|
||||||
-- </a>
|
|
||||||
-- </section>
|
|
||||||
date = require "date"
|
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"
|
path = require "sitegen.path"
|
||||||
moon = require("moon")
|
moon = require("moon")
|
||||||
common = require("sitegen.common")
|
common = require("sitegen.common")
|
||||||
@ -58,22 +7,21 @@ extract_date = (source) -> string.match path.filename(source), "%d+%-%d%d%-%d%d"
|
|||||||
format_date = (str) -> date(str)\fmt "%b %d, %Y"
|
format_date = (str) -> date(str)\fmt "%b %d, %Y"
|
||||||
publish_date = (path) -> format_date extract_date path
|
publish_date = (path) -> format_date extract_date path
|
||||||
|
|
||||||
html ->
|
|
||||||
posts = [{
|
posts = [{
|
||||||
id: p.meta.id
|
id: p.meta.id
|
||||||
tgt: p.meta.target
|
tgt: p.meta.target
|
||||||
src: p.source
|
src: p.source
|
||||||
title: p.meta.title or p.meta.id
|
title: p.meta.title or p.meta.id
|
||||||
blurb: p.meta.blurb
|
blurb: p.meta.blurb
|
||||||
} for _, p in pairs page.site.pages when p.meta.template == "blog"]
|
} for _, p in pairs 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
|
table.sort posts, (a, b) -> a.src > b.src
|
||||||
|
|
||||||
|
html ->
|
||||||
[tag["section"] {
|
[tag["section"] {
|
||||||
tag["h3"] { tag["a"] { href: p.tgt .. ".html", p.title }}
|
tag["h3"] { tag["a"] { href: p.tgt .. ".html", p.title }}
|
||||||
tag["time"] { publish_date p.src }
|
tag["time"] { publish_date p.src }
|
||||||
"—" .. if p.blurb then " #{p.blurb}" else ""
|
{"—", if p.blurb then text(p.blurb)}
|
||||||
tag["a"] { class: "read-post-link", href: p.tgt .. ".html", "Read post →"}
|
tag["a"] { class: "read-post-link", href: p.tgt .. ".html", "Read post →"}
|
||||||
} for _, p in ipairs posts]
|
} for _, p in ipairs posts]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user