Render blurbs as markdown

This commit is contained in:
Catalin Constantin Mititiuc 2025-05-23 18:14:36 -07:00
parent 33a2e4ab93
commit dc0ac71f98

View File

@ -18,6 +18,8 @@ rend = "renderers.markdown"
require(rend).cmd = "pandoc --mathjax >" require(rend).cmd = "pandoc --mathjax >"
-- Replace the default markdown renderer with our custom renderer -- Replace the default markdown renderer with our custom renderer
-- TODO we shouldn't remove it because it is still searched for in some places
-- example https://github.com/leafo/sitegen/blob/ac9b7c199ed7adb32064b056a438cbaed8c71d23/sitegen/renderers/html.moon#L53
Site.default_renderers = for v in *Site.default_renderers Site.default_renderers = for v in *Site.default_renderers
if v\find "markdown" then rend else v if v\find "markdown" then rend else v
@ -92,13 +94,15 @@ sitegen.create =>
html.build -> html.build ->
import section, h3, time, a from tag import section, h3, time, a from tag
md = @site\get_renderer "renderers.markdown"
return for post in *posts return for post in *posts
{:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta {:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta
url = rootname post\url_for! url = rootname post\url_for!
md = post.site\get_renderer "renderers.markdown"
blurb = md\render @, blurb if blurb if blurb
if blurb then blurb = html.builders.raw! blurb blurb = raw md\render @, blurb
blurb.text = unpack [v for v in blurb.text\gmatch "<p>(.-)</p>"]
section { section {
h3 { a { title or titleize_slug(id), href: url }} h3 { a { title or titleize_slug(id), href: url }}