Try client-side routing for all sx-get link clicks, not just boost links
bind-event now checks tryClientRoute before executeRequest for GET clicks on links. Previously only boost links (inside [sx-boost] containers) attempted client routing — explicit sx-get links like ~nav-link always hit the network. Now essay/doc nav links render client-side when possible. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -388,15 +388,25 @@
|
||||
(dom-has-attr? el "href")))
|
||||
(prevent-default e))
|
||||
|
||||
;; Delay modifier
|
||||
(if (get mods "delay")
|
||||
;; For GET clicks on links, try client-side routing first
|
||||
(if (and (= event-name "click")
|
||||
(= (get verbInfo "method") "GET")
|
||||
(dom-has-attr? el "href")
|
||||
(not (get mods "delay"))
|
||||
(try-client-route (url-pathname (get verbInfo "url"))))
|
||||
;; Client route succeeded — push state, scroll to top
|
||||
(do
|
||||
(clear-timeout timer)
|
||||
(set! timer
|
||||
(set-timeout
|
||||
(fn () (execute-request el verbInfo nil))
|
||||
(get mods "delay"))))
|
||||
(execute-request el verbInfo nil)))))
|
||||
(browser-push-state (get verbInfo "url"))
|
||||
(browser-scroll-to 0 0))
|
||||
;; Fall through to server fetch
|
||||
(if (get mods "delay")
|
||||
(do
|
||||
(clear-timeout timer)
|
||||
(set! timer
|
||||
(set-timeout
|
||||
(fn () (execute-request el verbInfo nil))
|
||||
(get mods "delay"))))
|
||||
(execute-request el verbInfo nil))))))
|
||||
(if (get mods "once") (dict "once" true) nil))))))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user