first commit
This commit is contained in:
commit
5b16dd6774
24 files changed
+9575
No files matched your search
@@ -0,0 +1,46 @@
|
||||
(ns website.core
|
||||
(:require [reagent.core :as reagent :refer [atom]]
|
||||
[secretary.core :as secretary :include-macros true]
|
||||
[accountant.core :as accountant]))
|
||||
|
||||
;; -------------------------
|
||||
;; Views
|
||||
|
||||
(defn home-page []
|
||||
[:div [:h2 "Welcome to website"]
|
||||
[:div [:a {:href "/about"} "go to about page"]]])
|
||||
|
||||
(defn about-page []
|
||||
[:div [:h2 "About website"]
|
||||
[:div [:a {:href "/"} "go to the home page"]]])
|
||||
|
||||
;; -------------------------
|
||||
;; Routes
|
||||
|
||||
(defonce page (atom #'home-page))
|
||||
|
||||
(defn current-page []
|
||||
[:div [@page]])
|
||||
|
||||
(secretary/defroute "/" []
|
||||
(reset! page #'home-page))
|
||||
|
||||
(secretary/defroute "/about" []
|
||||
(reset! page #'about-page))
|
||||
|
||||
;; -------------------------
|
||||
;; Initialize app
|
||||
|
||||
(defn mount-root []
|
||||
(reagent/render [current-page] (.getElementById js/document "app")))
|
||||
|
||||
(defn init! []
|
||||
(accountant/configure-navigation!
|
||||
{:nav-handler
|
||||
(fn [path]
|
||||
(secretary/dispatch! path))
|
||||
:path-exists?
|
||||
(fn [path]
|
||||
(secretary/locate-route path))})
|
||||
(accountant/dispatch-current!)
|
||||
(mount-root))
|
||||
Reference in new issue
Block a user