Skip to content

Commit 2aa4bb1

Browse files
authored
Fix relative links (#784)
By removing trailing slash.
1 parent c0b56ff commit 2aa4bb1

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changes can be:
99
## Unreleased
1010

1111
* 💫 Detect and throw on infinte loops during presentation
12+
* 🐜 Fix relative links by removing trailing slash, fixes [#783](https://github.com/nextjournal/clerk/issues/783)
1213

1314
## 0.18.1158 (2025-11-17)
1415

notebooks/links.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ The same functionality is available in the SCI context when building render func
6363
Links should work inside markdown as well.
6464

6565
* [HTML](../notebooks/viewers/html) (relative link)
66+
* [HTML](./viewers/html) (relative link)
67+
* [HTML](viewers/html) (relative link)
6668
* [HTML](clerk/doc-url,"notebooks/viewers/html") (doc url, currently not functional)

src/nextjournal/clerk/render.cljs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,7 @@
861861
(let [path (.-pathname url)
862862
edn-path (str path (when (str/ends-with? path "/") "index") ".edn")]
863863
(.pushState js/history #js {:edn_path edn-path} ""
864-
(str (cond-> path
865-
(not (str/ends-with? path "/"))
866-
(str "/")) (.-hash url))) ;; a trailing slash is needed to make relative paths work
864+
(str path (.-hash url)))
867865
(fetch+set-state edn-path)))))
868866

869867
(defn load->fetch [{:keys [current-path]} _e]

0 commit comments

Comments
 (0)