on https://github.clerk.garden/ it says
1. Add a :nextjournal.clerk to :aliases in your deps.edn file:
when the . should likely be a /
1. Add a :nextjournal/clerk to :aliases in your deps.edn file:
correct, thank you!
@mkvlr np. I have another question about garden. I don't understand this bit:
> ;; if you just want to build one notebook, set :index
by 'set' do we mean, provide a path to a file that can be interpreted as an index?
backing up, what i want to do have garden build a collection of notebooks, and also host the index page, so people can see all my notebooks. i'm thinking each notebook will be it's own gitsubmodel of the larger git notebook*s* directory.
So what i would provide clerk is the url to the github top level repo, in that case, how do i configure my deps.edn? Assuming my files are like this
/clerk-notebooks/deps.edn <--- what should go in this
clerk-notebooks/notebook1/deps.edn
clerk-notebooks/notebook2/deps.edn
clerk-notebooks/notebook1/src/some-clj-file-that-will-become-a-wepage.clj
... etc...
I'm not sure what would go in the top level deps.edn.
{:aliases
{:nextjournal/clerk
{
:exec-fn nextjournal.clerk/build!
:exec-args {:index ???}}}}
I believe i basically want what clerk.vision is dong or maybe the clerk demo page https://github.clerk.garden/nextjournal/clerk-demo/commit/ff0b806e7da3e42865803bc3ceeb26444e136a51/
looking at the demo page's deps.edn aliases...
{:nextjournal/clerk {:extra-paths ["datasets"]
:exec-fn nextjournal.clerk/build!
;; notebooks to be built, accepts globs patterns
:exec-args {:git/url ""
:paths ["index.md"
"notebooks/slideshow.md"
"notebooks/introduction.clj"
"notebooks/data_science.clj"
"notebooks/images.clj"
"notebooks/logo.clj"
"notebooks/semantic.clj"
"notebooks/sicmutils.clj"
"notebooks/rule_30.clj"
"notebooks/zipper_with_scars.clj"]}
:main-opts ["-m" "babashka.cli.exec"]}}
So its calling build and passing it a git url, some main-opts, a index.md (i guess clerk reads the .md, pulls out the code, runs it, then inserts the result?)
The whole thing seems kinda close to understandable, but i'm not quiet seeing the easy path.@drewverlee yes to your q regarding :index
for your larger question, you want build a collection of notebooks where the individual repos are in different git repos?
you only need to set index if you want to override clerk‘s buitin one
Gotcha. I'm probably having trouble seeing what i want here because i don't need it yet (e.g i don't have two notebooks) I'm guessing once i do, the options for linking to them will be very obvious (e.g i just have a separate web page that literally holds links [:a {:src ...}] to them lol)
you’ll need to use clerk/doc-url for the link targets
like in https://github.com/nextjournal/clerk/blob/main/index.clj
what does that do?
make sure the links work when running using a clerk server as well as during build
gotcha.
my local notebook build works, but my garden build fails (should i keep asking garden question here)? Here is the garden https://build.github.clerk.garden/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/81a3c1dbdadec47342d7ee332073b0bd33139923/?update=1. here is the https://github.com/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs I'm guessing this has to do with git deps git urls not being about to pull in a deps? Or clerk not being about to? The library involved in the deps issue is arrowic and it's being used to build a notebook http://arrowic/arrowic%20{:mvn/version%20"0.1.1"} with the mvn/version (as opposed to git/url). I can use mvn/version, but then i would either need to not use the latest version of arrowic or publish the latest to maven.
does :git/sha work? think plain :sha was deprecated a while back
hmm
trying it now...
you can try upgrading your Clojure cli and see if you can repro the error locally with clojure -X
still fails with git/sha.
e.g updated sha -> git/sha then did the ?update=1
actually, let me triple check..
yea the clerk build failed with the git/sha keyword to: https://build.github.clerk.garden/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/759309af445333af1e7065756537a8d55a6254a6/?update=1 https://github.com/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/759309af445333af1e7065756537a8d55a6254a6
sec, trying…
@mkair ~/d/seven-troubleshooting-tips-for-squashing-software-bugs (master)> clojure -X:nextjournal/clerk
👷🏼 Clerk is building 1 notebooks…
🧐 Parsing… Done in 339.019ms. ✅
🔬 Analyzing… Done in 640.721ms. ✅
🔨 Building "src/drewverlee/seven_troubleshooting_tips_for_squashing_software_bugs.clj"… Done in 2337.320ms. ✅
📦 Static app bundle created in 41.755ms. Total build time was 3359.783ms.ok, works for me locally, too
don’t understand what’s going on either 😑 I’ll need to get back to you on this in the coming days. Might be that we need to add something to babashka to avoid this error
clojure.lang.ExceptionInfo: Method serverClose on class org.httpkit.server.AsyncChannel not allowed! {:type :sci/error, :line nil, :column nil, :file nil}no worries. Thanks for looking into it!
i was able to deploy when my deps specified the maven/jar and not a git hurl: https://github.clerk.garden/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/495a9ce245b4e2b7a57d431ff5ebff03f49782e6/ https://github.com/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/495a9ce245b4e2b7a57d431ff5ebff03f49782e6
strange…
does io.github.jackrusher/arrowic {:git/sha ,,,} work?
the article looks great btw 👏
why would io.github.jackrusher/arrowic {:git/sha ,,,} work? is that what your supposed to do for the ... idk, namespace side of the slash? ill give it a try. Thanks If you read the whole thing, please give feedback! If you can solve the 'bug' help me understand it 🙂 laughcry
one thing that i'm going to add to my workflow is a dalle-3 to picture tool. So i can produce images and inline them easily. I mean, its easy to overdo. But it's a powerful way to add decent pictures. Idk, maybe it makes the article worse though? i suppose its all about how well done it is?
though, on with a less then ideal internet connection, those pictures are loading really slow...
actually, i need to proof read this again. All the tech stuff gets in the way of really looking carefully at the wording...
annoyingly the best place to edit the english is in chrome, looking at the github repo, where i can have grammarly on.
yep, not focusing enough on the prose is a downside of authoring in clerk I’ve certainly experienced myself
I'm trying to work on non-trivial clerk viewers... and it's been... humbling.. 😬. I'll try to explain here what I'm trying to do 🧵 ...
I want to write a custom viewer for a nested data structure. This viewer needs to do its own transform-fn logic, render its own things, and at certain locations I want it to render generic data, for which I want clerks' standard "pick a viewer" and "recursion" magic to happen.
Am I clear? is there a way to achieve that?
Here's a rough idea of what I'm trying to do (of course it's wrong):
(def test-viewer-inner
{:name `test-viewer-inner
:pred (fn [maybe] (and (map? maybe) (contains? maybe :test-1)))
:transform-fn (comp clerk/mark-presented
(clerk/update-val
(fn [v]
(clerk/html [:div.inline-flex.gap-2
[:strong "test-viewer-inner:"]
[:pre (prn-str v)]]))))})
(def test-viewer
{:name `test-viewer
:pred (fn [maybe] (and (map? maybe) (contains? maybe :test)))
:transform-fn (fn [wrapped]
(-> wrapped
clerk/mark-preserve-keys
clerk/mark-presented
(update :nextjournal/value
(fn [value]
{:extra-data [1 2 3 "four"]
:value value }))))
:render-fn '(fn [{:keys [extra-data value presented-value]}]
(let []
[:div.border.border-black.px-1.py-2
[:h3 "test-viewer:"]
[:div
[:h4 "value:"]
[nextjournal.clerk.render/inspect value]]]))})
(clerk/add-viewers! [test-viewer test-viewer-inner])
{:test true
:a-number 4
:a-string "testing"
:a-nested-value-a {:test-1 "value-A"} ;; <-- I want `test-viewer-inner` to render this
}
I do understand that the viewers/recursion happens on the server-side, so I guess I somehow have to do something with value on transform-fn, but I don't find the way.
I'd appreciate any help! Thanks!(so... I guess I wished I could use clerk/mark-presented only on :extra-data on the example)