commit 85533b6e5003cc01a84cb5959bcd0a7ade8fccb5
parent f8e35511ea77434317517ab32b07dfe454889c34
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 21 Jul 2025 14:13:31 +0100
add markdown post rendering
Diffstat:
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/main.fnl b/main.fnl
@@ -5,7 +5,8 @@
(local http-util (require :http.util))
(local http-version (require :http.version))
(local ce (require :cqueues.errno))
-
+(local lcmark (require :lcmark))
+
(local server (require :server))
(local textile (require :textile))
@@ -186,14 +187,18 @@
(let [s { :write #(stream:write_chunk $2) } ]
(case route.command
:show
- (let [path (. (. post-index route.slug) :full-path)]
+ (let [post (. post-index route.slug)
+ path (. post :full-path)]
(print :path path)
(with-open [f (io.open path )]
(when f
(let [_ (frontmatter f)]
- (each [_ el (ipairs (textile.parse f))]
- (print (view el))
- (textile.to-html s el)))))
+ (if (string.match path "%.textile$")
+ (each [_ el (ipairs (textile.parse f))]
+ (textile.to-html s el))
+ (stream:write_chunk
+ (lcmark.convert (f:read "*a") "html" { :yaml_parser #($1) }))
+ ))))
(stream:write_chunk "" true))
:search
(stream:write_chunk "hello this is a search page" true))))