aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <msunet@shellblade.net>2021-12-30 03:45:24 -0800
committerMarc Sunet <msunet@shellblade.net>2021-12-30 03:45:24 -0800
commit8c186f6e9145666cbabd5cca0a250d74a1e009d7 (patch)
treed69f1642762e2c82598baad2236c152cd1eb4578
parent5d6ec23f261452a138ab081303b19eaf454006ee (diff)
Simplify file processing.
-rw-r--r--webgen.janet10
1 files changed, 4 insertions, 6 deletions
diff --git a/webgen.janet b/webgen.janet
index 1b21544..922dba0 100644
--- a/webgen.janet
+++ b/webgen.janet
@@ -40,10 +40,8 @@
40 40
41(defn process-html 41(defn process-html
42 "Process the given HTML contents, applying the website's template." 42 "Process the given HTML contents, applying the website's template."
43 [template variables path contents] 43 [template contents]
44 (substitute-variables variables path 44 (string/replace "${CONTENTS}" contents template))
45 (string/replace "${CONTENTS}" contents
46 template)))
47 45
48(defn process-files 46(defn process-files
49 "Process the files in the source directory and write the results to the 47 "Process the files in the source directory and write the results to the
@@ -61,8 +59,8 @@
61 (def processed-contents 59 (def processed-contents
62 (match ext 60 (match ext
63 ".css" (substitute-variables variables src-filepath (filesystem/read-file src-filepath)) 61 ".css" (substitute-variables variables src-filepath (filesystem/read-file src-filepath))
64 ".html" (substitute-variables variables src-filepath process-html template (filesystem/read-file src-filepath)) 62 ".html" (substitute-variables variables src-filepath (process-html template (filesystem/read-file src-filepath)))
65 ".md" (substitute-variables variables src-filepath process-html template (markdown-file-to-html src-filepath)) 63 ".md" (substitute-variables variables src-filepath (process-html template (markdown-file-to-html src-filepath)))
66 _ nil)) # nil means we copy the file as is. 64 _ nil)) # nil means we copy the file as is.
67 (var dst-filepath (string/replace src-dir build-dir src-filepath)) 65 (var dst-filepath (string/replace src-dir build-dir src-filepath))
68 (set dst-filepath 66 (set dst-filepath