-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat: Support org-file parsing to hiccup content #1
base: master
Are you sure you want to change the base?
Conversation
We really only need one function from this module -- `clj-org.org/parse-org` This function takes a string and returns a map, with one key `:content` mapping to a hiccup structure. Exactly what I need!
I haven't tried yet, but you might be able to directly add |
example/site.clj
Outdated
(def-asset home-page | ||
{:path "/index.html" | ||
:type :html | ||
:data (page "Hello world" [:p "This is magic"])}) | ||
:data (page "Hello world" [:a {:href "/about.html"} "This is a blog link."])}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer using the built in asset-path
function instead of manually writing the path. Eg:
(page "Hello world" [:a {:href (asset-path about-page)} "This is a blog link"])
Appreciate the comments! And apologies, I think if this were anyone else's project I wouldn't have opened a WIP PR like this. |
I don't mind! Reminds me of the good ol' days! |
This is done by calling a parse-org function, the result of composing slurp and another function by the same name from clj-org.org. This lets us easily call parse-org on a path in the site.clj and get the hiccup content back.
d3bac48
to
b013a6f
Compare
Okay, I was giving this thought today: The spirit of this project seems to be getting up to speed with a singe statik page as fast as possible. This means that anything adding complexity or extending functionality should be either dirt cheap at the top level, or explicitly supported as something nice in the DLS. I will argue that consuming markup and generating an html asset from it is pretty inline with the project, so the question is how much explicitly to support it in the DSL. Adding a helper function to return the title and content of a given org file is alright, but I want to think about whether this makes sense as it's own asset type, or at least a better top-level function. One can imagine applying a directory of org files to a template function, generating the equivalent of an explicit |
Sorry on the delay on this. The |
Opening this PR so you can see where I'm at here. Turns out there's a library that exposes an
org->hiccup function
-- wondrous! Sadly, it only takes a string, so I tried slurping it and realizedsci doesn't supportwe didn't exposeslurp
in the injected namespaces. Ok, understood. Looks like I'll need to do it incore.clj
or something.Basically just putting this up so I have a place to talk it.