mirror of
https://codeberg.org/bunbun/bunbun.dev
synced 2025-01-22 12:44:29 -08:00
20 lines
654 B
Plaintext
20 lines
654 B
Plaintext
|
(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
|