Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Keep legacy links working [temporary]
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Jan 23, 2024
1 parent a171aa5 commit 9e7867a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src-contrib/electric_fiddle/main.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

(e/defn NotFoundPage [& args] (e/client (dom/h1 (dom/text "Page not found: " (pr-str r/route)))))

(e/defn RedirectLegacyLinks! [link]
;; Keep existing links working.
;; Demos used to be identified by their fully qualified name - e.g. `hello-fiddle.fiddles/Hello
;; They are now represented by an s-expression - e.g. `(electric-tutorial.demo-color/Color h s l)
(if (or (seq? link) (vector? link))
link
(do (r/Navigate!. [(list link)])
nil)))

(e/defn Main [ring-req]
(e/server
(binding [e/http-request ring-req]
Expand All @@ -17,7 +26,7 @@
(r/router (r/HTML5-History.)
(dom/pre (dom/text (pr-str r/route)))
(let [route (or (ffirst r/route) `(Index)) ; route looks like {(f args) nil} or nil
[f & args] route]
[f & args] (RedirectLegacyLinks!. route)]
(set! (.-title js/document) (str (some-> f name (str " – ")) "Electric Fiddle"))
(case f
`Index (Index.)
Expand Down

0 comments on commit 9e7867a

Please sign in to comment.