Related: I'm trying to add a static page, so I edit the pages in static.clj https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/example/src/example/static.clj#L46 to include {"/page" page-hiccup} Now "/page" loads, but it's loaded as a file to download, not a webpage. If I set the path to "/page.html" and link to that, the page loads as a webpage as expected. Is this the intended usage, or am I missing a step?
It'll work if you add a terminal slash (`{"/page/" page-hiccup}`). In that case, Biff writes the file to /page/index.html
(see https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/src/biff/system.clj#L192), and /page
requests will get redirected to /page/
.
Perhaps I should add an in-code comment about that or something
The step that I was missing was that when I tried to create a "/page/" path, I think that we try to create the /page/index.html in the resources folder, but that directory /page did not exist for me so I had to manually create /page before it was able to access the directory.
https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/src/biff/system.clj#L195 Is this the call to export-rum where the html is generated? I'm trying to generate html5 pages, so I'm trying to use hiccup/html5 instead.
yes, that's where the html is generated. just below that line there's a io/make-parents
call which should create the page
directory. do you have a stack trace handy?
Also, are you generating the html with hiccup/html5
first, e.g. {"/page/" (hiccup/html5 some-hiccup)}
? if not, biff will try to render it with rum which might break.
Checked it again, it's automatically creating the folder as expected. I must've have been mistaken somewhere
My intent was to replace rum-export with a version that uses hiccup/html5
:thumbsup: should be pretty straightforward. Don't set :biff/static-pages
, and instead, thread the result of start-biff
through your own custom fn, e.g.
(defn export-html5 [{:keys [yourapp.biff.static/root] :as sys}]
; write the html to the root directory
sys)
(-> ...
(start-biff 'yourapp)
export-html5)
(edit: include yourapp
in the key namespace)(aside: I've been thinking lately about how the yourapp.biff/foo
vs biff/foo
thing is confusing and in most cases unnecessary. The purpose of it was to allow multiple start-biff
calls in the same process, i.e. so they could have non-conflicting namespaces. But most people will likely only be running one biff instance, at least at first, so maybe better to turn off the namespace shenanigans by default but keep them as an option for those who want to run multiple instances)
just made an issue: https://github.com/jacobobryant/biff/issues/46