mirror of
https://codeberg.org/bunbun/bunbun.dev
synced 2025-06-07 17:49:55 -07:00
initial
This commit is contained in:
19
page-handler.fnl
Normal file
19
page-handler.fnl
Normal file
@ -0,0 +1,19 @@
|
||||
(local cmark (require :cmark))
|
||||
(local lfs (require :lfs))
|
||||
|
||||
(local page-handler {})
|
||||
|
||||
(fn page-handler.read-pages []
|
||||
(each [file (lfs.dir :pages)]
|
||||
(when (and (not= file ".") (not= file ".."))
|
||||
(local markdown (with-open [markdown-file (io.open (.. :pages/ file) :r)]
|
||||
(markdown-file:read :*a)))
|
||||
|
||||
(local html-template (with-open [html-template-file (io.open :template.html :r)]
|
||||
(html-template-file:read :*a)))
|
||||
|
||||
(local html (cmark.markdown_to_html markdown (markdown:len) cmark.OPT_UNSAFE))
|
||||
|
||||
(tset _G.files (file:match "(.+)%..+") (html-template:format html)))))
|
||||
|
||||
page-handler
|
Reference in New Issue
Block a user