Skip to content

Commit

Permalink
feat: redirect to play from fiddle
Browse files Browse the repository at this point in the history
  • Loading branch information
Akeboshiwind committed May 20, 2024
1 parent 5048214 commit c3fedb7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/xt_play/app.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@
(rf/dispatch-sync [::init js/xt_version])
(r-dom/render [client/app] (js/document.getElementById "app")))

(defn redirect? []
(let [hostname js/window.location.hostname]
(and (not= hostname "localhost")
(not= hostname "play.xtdb.com"))))

(defn redirect! []
(set! js/window.location.href
(str "https://play.xtdb.com" js/window.location.search)))

(defn ^:export init []
;; init is called ONCE when the page loads
;; this is called in the index.html and must be exported
;; so it is available even in :advanced release builds
(log/info :init "init")
;; Redirect from fiddle to play.xtdb.com
(when (redirect?)
(redirect!))
(start!))

;; this is called before any code is reloaded
Expand Down

0 comments on commit c3fedb7

Please sign in to comment.