 (defn path-join [& paths]
   (apply (.' (js/require "path") :join) paths))
 
-(defn read-css []
-  (string/join "\n" (map read-file (:css-infiles @config))))
-
-(defn write-resources [dir]
-  (write-file (path-join dir (:css-file @config))
-              (read-css)))
+(defn read-css [{cssfiles :css-infiles}]
+  (string/join "\n" (map read-file cssfiles)))
+
+(defn write-resources [dir {file :css-file :as conf}]
+  (write-file (path-join dir file)
+              (read-css conf)))
 
 
 ;;; Main entry points

       [:link {:href (str css-file timestamp) :rel 'stylesheet}]
       [:title title]]
      [:body
       [:div {:id main-div} (danger :div body)]
       (danger :script (str "var pageConfig = "
                            (-> page-conf clj->js js/JSON.stringify)))
       [:script {:src main :type "text/javascript"}]]])))

(defn gen-page [page-name timestamp]
  (dispatch [:set-page page-name])
  (let [b (r/render-component-to-string (body))]
    (str "<!doctype html>"
         (html-template {:title (:title @config)
                         :body b
                         :page-conf {:page-name page-name}
                         :timestamp timestamp}))))

(defn mkdirs [f]
  (let [fs (js/require "fs")

(defn ^:export genpages [opts]
  (log "Generating site")
  (swap! config merge (js->clj opts :keywordize-keys true))
  (let [{:keys [site-dir pages] :as conf} @config
        conf (assoc conf :timestamp (str "?" (js/Date.now)))]
    (doseq [f pages]
      (write-file (path-join site-dir (as-relative f))
                  (gen-page f conf)))
    (write-resources site-dir conf))
  (log "Wrote site"))

(defn start! [site-config]
