Skip to content

Commit d07496f

Browse files
mkphilippamarkovics
authored andcommitted
Support showing notebooks outside of working dir
By preserving absolute url for them.
1 parent 262e884 commit d07496f

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
@@ -198,7 +198,8 @@
198198
(string? file-or-ns)
199199
(when (fs/exists? file-or-ns)
200200
(fs/unixify (cond->> file-or-ns
201-
(fs/absolute? file-or-ns)
201+
(and (fs/absolute? file-or-ns)
202+
(not (str/starts-with? (fs/relativize (fs/cwd) file-or-ns) "..")))
202203
(fs/relativize (fs/cwd)))))
203204

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

0 commit comments

Comments
 (0)