Created
December 7, 2023 12:32
-
-
Save phunanon/5063028634442b7e4001d3e465d11bab to your computer and use it in GitHub Desktop.
Builds HTML files with %dep.html% substitution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import "phunanon/fs") | |
(import "phunanon/dotenv") ────── | |
(-> (dotenv) :www (var www)) | |
(-> (ls "*.html") | |
(var names) | |
(juxt _ (map (comp read trim))) | |
(... kv-dict) | |
(var files)) | |
(-> files | |
@(map-vals #(reduce #(replace (str '%' %1 '%' ) (files %1) %) % names)) | |
@(map-keys @(str www "/")) | |
(map (... write))) | |
www | |
(function map-keys f d ─────────────────────────────────────────────────────── | |
(.. dict (flat-map (fn [k v] [(f k) v]) d))) | |
(function map-vals f d | |
(.. dict (flat-map (fn [k v] [k (f v)]) d))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment