                                            (re-pattern (str page "$")) "")
                                           (string/replace #"/*$" ""))))
                     (History.)))
-        (evt/listen hevt/NAVIGATE #(when (.-isNavigation %)
-                                    (dispatch [:set-page (.-token %)])))
+        (evt/listen EventType.NAVIGATE #(when (.-isNavigation %)
+                                          (dispatch [:set-page (.-token %)])))
         (.setEnabled true))
-      (let [p (if (and page (not html5) (-> history .getToken empty?))
+      (let [token (.getToken history)
+            p (if (and page (not html5) (empty? token))
                 page
-                (.getToken history))]
+                token)]
         (dispatch [:set-page p])))))
 
 (defn to-relative [f]

(ns sitetools.core
  (:require [clojure.string :as string]
            [goog.events :as evt]
            [goog.history.EventType :as hevt]
            [reagent.core :as r]
            [reagent.debug :refer-macros [dbg log dev?]]
            [reagent.interop :as i :refer-macros [.' .!]])
  (:import goog.History
           goog.history.Html5History))

(when (exists? js/console)
  (enable-console-print!))

(defn rswap! [a f & args]
  ;; Like swap!, except that recursive swaps on the same atom are ok,

   child])

(defn main-content []
  (get-in @config [:current-page :content]))


;;; Static site generation

(defn base [page]
  (let [depth (->> page to-relative (re-seq #"/") count)]
    (->> "../" (repeat depth) (apply str))))

(defn danger [t s]
  [t {:dangerouslySetInnerHTML {:__html s}}])
