    child])
 
 (defn main-content []
-  (let [{comp :main-content} @config]
+  (let [comp (get-in @config [:current-page :content])]
     (assert (vector? comp))
     comp))
 


(defonce history nil)

(defn demo-handler [state [id x y :as event]]
  (case id
    :set-content (let [title (if y
                               (str (:title-prefix state) y)
                               (str (:default-title state)))]
                   (assert (vector? x))
                   (when r/is-client
                     (set! js/document.title title))
                   (assoc state :main-content x :title title))
    :set-page (do (assert (string? x))
                  (let [{pages :pages} state
                        p (get pages x (get pages "/index.html"))]
                    (-> state
                        (assoc :page-path x)
                        (recur [:set-content (:content p) (:title p)]))))
    :goto-page (do
                 (assert (string? x))
                 (when-some [h history]
                   (.setToken h x)
                   (r/next-tick #(set! js/document.body.scrollTop 0))


(defn gen-page [page-path conf]
  (dispatch [:set-page page-path])
  (let [conf (merge conf @config)
        b (:body conf)
        _ (assert (vector? b))
        bhtml (r/render-component-to-string b)]
    (str "<!doctype html>\n"
         (html-template (assoc conf
                               :page-conf {:page-path page-path}
                               :title (-> conf :current-page :title)
                               :body-html bhtml)))))

(defn fs [] (js/require "fs"))
