Skip to content

Commit 04e2d91

Browse files
committed
Support showing notebooks outside of working dir
By preserving absolute url for them.
1 parent 1da3837 commit 04e2d91

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/nextjournal/clerk/render.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@
154154

155155
(defn history-push-state [{:as opts :keys [path fragment replace?]}]
156156
(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)))) ))
157+
(j/call js/history (if replace? :replaceState :pushState) (clj->js opts) "" (str (.. js/document -location -origin)
158+
"/" path (when fragment (str "#" fragment))))))
158159

159160
(defn handle-history-popstate [^js e]
160161
(when-let [{:as opts :keys [path]} (js->clj (.-state e) :keywordize-keys true)]

src/nextjournal/clerk/webserver.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@
182182
(string? file-or-ns)
183183
(when (fs/exists? file-or-ns)
184184
(fs/unixify (cond->> file-or-ns
185-
(fs/absolute? file-or-ns)
185+
(and (fs/absolute? file-or-ns)
186+
(not (str/starts-with? (fs/relativize (fs/cwd) file-or-ns) "..")))
186187
(fs/relativize (fs/cwd)))))
187188

188189
:else (str file-or-ns)))

0 commit comments

Comments
 (0)