forked from nat/natalieee.net
code for blog/thoughts
This commit is contained in:
@ -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))))))))
|
||||
|
Reference in New Issue
Block a user