metasoarous / toto

Static site generation in Clojure (with live code reloading!)
Eclipse Public License 1.0
111 stars 3 forks source link

Overriding head #3

Closed avocade closed 3 years ago

avocade commented 3 years ago

We can't get the overriding options to work for head, have tried adding these options to our build config map:

(toto/build!
  {:from "site-src/"
   :to "build/"
   :omit-styles? true
   :header-extras [[:title "Testing"]]})

But nothing seems to be passed along.

Re: the following docs:

Other options passed through to the build specs will be passed through to the compile function. In particular, you can specify options like :omit-styles? to leave out the default styles, or :header-extras to add your own content to the head of the resulting HTML documents.

eneroth commented 3 years ago

The only thing passed to html-head is {:to-format :html}, so I'm guessing this is hard-coded somewhere, rather than merged in with options provided from build!. I'm unable to make sense of where, though.

eneroth commented 3 years ago

So it seems like html-head is not used in the output at all, but rather it is the index.html in resources that's used?

metasoarous commented 3 years ago

Hi @avocade and @eneroth. Thanks for posting.

It looks like these options weren't getting passed through the call to export! in build-and-view-file! (which build! calls out to). This has been fixed in a the 0.0.1-alpha2 release.

However, please note that style changes will not be reflected in the live view (unfortunately; see #5). As you suggest @eneroth, this is because the index.html is what is served for the live view. However, for the sake of clarity, this is not at all involved in the statically compiled output. Happy to accept a PR on this if anyone feels like sorting out a good way of handling that.

Thanks again for bringing this to my attention!

avocade commented 3 years ago

Great re: the options! Thanks, will try out the new version.

Yeah, I ran into this issue as well with the index.html in toto being only used for live views and the code for the rendered files… That's extremely frustrating since we of course need to have a consistent view of what we're building. We'll see if we can come up with a solution for that. Maybe rendering the toto index.html file from hiccup and spitting it out to public/ on startup, using the same code as html-head?

metasoarous commented 3 years ago

Thanks for the follow up.

That's an interesting idea, and something like that may work. I'll consider this further. It may be hard though since different pages could have different header content. But maybe there could be a way to customize the top level index.html with styles etc shared between pages. Won't cover testing that meta data like titles are coming through properly, but is maybe a good start.

For right now, you can try just including your styles inline in your hiccup templates, since those would override whatever global styles are in use if scoped properly. These should then work the same everywhere.

Thanks again!