code for blog/thoughts

This commit is contained in:
2025-05-11 15:33:29 -07:00
parent 3ae2641f83
commit f7bee74fcb
6 changed files with 123 additions and 4 deletions

View File

@ -4,12 +4,26 @@
(import templates *)
(import utils *)
(import hy.compiler [hy-eval])
(require hyrule.control [defmain])
(setv local-scope (locals))
(setv global-scope (globals))
(defmacro inherit [#* names]
(lfor name names
`(setx ~name (get local-scope (str (get '(~name) 0))))))
(defmacro enshrine [#* names]
(lfor name names
`(setv (get local-scope (str (get '(~name) 0))) ~name)))
(defmain []
(when (not (dir? "output"))
(mkdir "output"))
(for [path (glob "./pages/**/*" :recursive True)]
(when (in "__pycache__" path)
(continue))
@ -24,7 +38,10 @@
(do
(print f"building {path}")
(setv page-name (.split (cut path 2 -3) "/"))
(enshrine page-name)
(with [target (open (+ "./output/" (.join "/" (cut page-name 1 None)) ".html") "w")]
(.write target (form->html
(hy.eval (hy.read (with [source (open path "r")]
(.read source)))))))))))
(hy-eval (hy.read (with [source (open path "r")]
(.read source)))
:locals local-scope
:globals global-scope))))))))