 
 ;;; History
 
-(defn init-history []
+(defn init-history [page]
   (when-not history
-    (let [page (:page-name @config)
-          html5 (and page
+    (let [html5 (and page
                      (.isSupported Html5History)
                      (#{"http:" "https:"} js/location.protocol))]
       (doto (set! history


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

(defn start! [site-config]
  (swap! config merge site-config)
  (when r/is-client
    (let [page-conf (when (exists? js/pageConfig)
                      (js->clj js/pageConfig :keywordize-keys true))
          conf (swap! config merge page-conf)]
      (init-history (:page-name conf))
      (r/render-component (:body conf)
                          (js/document.getElementById (:main-div conf))))))
