2017-09-28 22:10:22 +00:00
|
|
|
(ns sitetools.prerender
|
|
|
|
(:require [reagent.debug :refer-macros [log]]
|
|
|
|
[sitetools.core :as tools]
|
|
|
|
[sitetools.server :as server]
|
2017-10-18 11:25:41 +00:00
|
|
|
[reagentdemo.core :as demo]))
|
2017-09-28 22:10:22 +00:00
|
|
|
|
|
|
|
(defn -main [& args]
|
|
|
|
(log "Generating site")
|
2017-10-18 11:25:41 +00:00
|
|
|
(demo/init!)
|
2017-09-28 22:10:22 +00:00
|
|
|
(let [conf @tools/config
|
|
|
|
conf (assoc conf :timestamp (str "?" (js/Date.now)))
|
|
|
|
{:keys [site-dir pages]} conf]
|
|
|
|
(doseq [f (keys pages)]
|
|
|
|
(server/write-file (->> f tools/to-relative (server/path-join site-dir))
|
|
|
|
(server/gen-page f conf)))
|
|
|
|
(server/write-resources site-dir conf))
|
2017-10-18 11:25:41 +00:00
|
|
|
(log "Wrote site")
|
|
|
|
(js/process.exit 0))
|
2017-09-28 22:10:22 +00:00
|
|
|
|
|
|
|
(set! *main-cli-fn* -main)
|