File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 140140
141141(declare clerk-eval )
142142
143- (defn ->URL [href]
143+ (defn ->URL [^js href]
144144 (js/URL. href))
145145
146146(defn handle-anchor-click [^js e]
147- (prn :handle-anchor-click e)
148147 (when-some [url (some-> e .-target closest-anchor-parent .-href ->URL)]
149148 (when (= (.-search url) " ?clerk/show!" )
150149 (.preventDefault e)
153152 (seq (.-hash url))
154153 (assoc :fragment (subs (.-hash url) 1 ))))))))
155154
156- (defn history-push-state [{:keys [path fragment replace?]}]
157- (when (not= path (some-> js/history .-state .-clerk_show))
158- (j/call js/history
159- (if replace? :replaceState :pushState )
160- #js {:clerk_show path} nil (str " /" path (when fragment (str " #" fragment))))))
155+ (defn history-push-state [{:as opts :keys [path fragment replace?]}]
156+ (when (not= path (some-> js/history .-state .-path))
157+ (j/call js/history (if replace? :replaceState :pushState ) (clj->js opts) " " (str " /" path (when fragment (str " #" fragment)))) ))
161158
162159(defn handle-history-popstate [^js e]
163- (prn :handle-history-popstate e)
164- (when-some [notebook-path (some-> e .-state .-clerk_show)]
160+ (when-let [{:as opts :keys [path]} (js->clj (.-state e) :keywordize-keys true )]
165161 (.preventDefault e)
166- (clerk-eval (list 'nextjournal.clerk.webserver/navigate! {:nav-path notebook-path
167- :skip-history? true }))))
162+ (clerk-eval (list 'nextjournal.clerk.webserver/navigate! {:nav-path path :skip-history? true }))))
168163
169164(defn render-notebook [{:as _doc xs :blocks :keys [bundle? css-class sidenotes? toc toc-visibility header footer]} opts]
170165 (r/with-let [local-storage-key " clerk-navbar"
You can’t perform that action at this time.
0 commit comments