clerk

narimiran 2025-12-05T05:25:57.481219Z

How to link the sibling notebook that works both for clerk/serve! and clerk/build!? I'm solving AoC and I have notebooks day01.clj, day02.clj, etc. To link the first one from the second one, I'm doing [Day 1](./day01) (I also tried [Day 1](day01)), which works correctly with clerk/serve!, but for clerk/build! it tries to open day02/day01/. Am I missing some setting that I should be using?

mkvlr 2025-12-05T05:31:19.223769Z

Try without the leading dot . On my phone right now but think this should work in both modes

mkvlr 2025-12-05T05:32:31.216929Z

or wait, use clerk/doc-url like in https://github.com/nextjournal/advent-of-clerk/blob/main/src/advent_of_clerk/index.clj#L35

narimiran 2025-12-05T05:41:27.580239Z

@mkvlr I've edited my message while you were writing your reply - I've tried both and neither works correctly. This doc-url stuff looks like an overkill for something that should just work (consistently).

mkvlr 2025-12-05T06:03:56.035569Z

@narimiran doc-url also doens’t work?

mkvlr 2025-12-05T06:11:32.046679Z

(clerk/html [:a {:href (clerk/doc-url "src/advent_of_clerk/day_01")} "To Day 1 hiccup"])

mkvlr 2025-12-05T06:11:43.862109Z

this works in serve, trying build! now…

narimiran 2025-12-05T06:14:42.580519Z

I want to have these links inline with the rest of markdown comment, e.g.:

;; We already did this in [Day 1](./day01) where we used...
I don't want to have to do something like:
;; We already did this in
(clerk/html .......)
;; where we used ...
(And I'm not even sure that would just continue the sentence?)

mkvlr 2025-12-05T06:15:55.000459Z

yeah then you’d need to write the whole paragraph in hiccup

mkvlr 2025-12-05T06:15:58.645399Z

agree that sucks

narimiran 2025-12-05T06:16:15.091939Z

ungh

narimiran 2025-12-05T06:17:32.328929Z

Why is there a difference between serve and build? I'm ok with using either ./day01 or ../day01 , just would like to be consistent between the two of them.

mkvlr 2025-12-05T06:19:59.292689Z

ok sorry this works

;; To [Day 1](/src/advent_of_clerk/day_01)

narimiran 2025-12-05T06:20:43.236149Z

Ok, I can work with that. I'll try it.

mkvlr 2025-12-05T06:21:17.832519Z

agree we should try to make relative links work

mkvlr 2025-12-05T06:26:04.355239Z

I filed https://github.com/nextjournal/clerk/issues/783

🍻 1
narimiran 2025-12-05T06:38:09.323899Z

> ;; To [Day 1](/src/advent_of_clerk/day_01) Doesn't work. Locally it should be /build/src/... and when pushed on GitHub it is /repo-name/src/....

mkvlr 2025-12-05T07:10:33.134289Z

it works if you serve it from build

mkvlr 2025-12-05T07:10:45.052229Z

needs to be the root folder atm

mkvlr 2025-12-05T07:11:09.916079Z

need to run now but will get back to this, Unsure if before next week though.

mkvlr 2025-12-05T11:09:01.413079Z

can you try https://github.com/nextjournal/clerk/pull/784?

mkvlr 2025-12-05T11:09:14.657349Z

so {:git/sha "de2186a9231fb2797de53783eef45702ec33308a"}

mkvlr 2025-12-05T11:09:22.448939Z

this should fix relative links

mkvlr 2025-12-05T11:10:15.685569Z

;; To [Day 2](day_02)

mkvlr 2025-12-05T11:11:14.329319Z

unless the webserver adds trailing slashes that is

mkvlr 2025-12-05T11:11:36.624329Z

it does work for me with python3 -m http.server

narimiran 2025-12-05T11:21:57.571829Z

@mkvlr at least locally, this seems to make both serve and build to correctly use both ./day02 and day02 relative links. 🍾

narimiran 2025-12-05T11:28:16.291499Z

unless the webserver adds trailing slashes that isOh, now I see that with the notebooks I've published (before this fix) when I open a notebook, there is a trailing slash which I cannot manually remove - the browser adds it back instantly. Ok, this explains why I had to do ../link if I wanted the links to work on published notebooks, but ./link worked locally.

mkvlr 2025-12-05T11:29:10.691859Z

yep, I’ve removed this behaviour in https://github.com/nextjournal/clerk/pull/784/files

mkvlr 2025-12-05T11:29:40.099359Z

there was a comment that the trailing slash was needed to fix relative links…

narimiran 2025-12-05T11:31:06.944439Z

Yeah, I've read the changes in that PR 🙂 Let's hope this fix won't get blocked on the account that this is a breaking change 🤞

mkvlr 2025-12-05T11:32:16.027039Z

I’ll need to sleep on it

mkvlr 2025-12-05T11:32:23.581499Z

hope you can use that git/sha in the meantime

👍 1
narimiran 2025-12-05T11:35:44.034309Z

Thanks for the help and the quick fix!! Really appreciate it!

❤️ 1