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


(defn gen-page [page-path conf]
  (dispatch [:set-page page-path])
  (let [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}
                               :body-html bhtml)))))

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


(defonce history nil)

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