seankross / postcards

💌 Create simple, beautiful personal websites and landing pages using only R Markdown.
Other
534 stars 78 forks source link

Enable injection of header, before/after body, and css fragments #18

Closed jjallaire closed 3 years ago

jjallaire commented 3 years ago

This enables users to provide custom CSS in the output format YAML, as well as enables additional custom and header/footer content.

Motivation is to be able to include postcards as the "About" page of a Distill website (and we need to inject the Distill site header/footer, as well as related CSS and JS).

seankross commented 3 years ago

Looks good to me and thanks for contributing. I am happy to send this patch to CRAN or if you think there may be more changes I can hold off.

jjallaire commented 3 years ago

There's some chance I'll give you another PR to make jquery an htmltools::htmlDependency (that would allow us to prevent multiple copies of jquery from being loaded)

seankross commented 3 years ago

That's a great idea. In that case I will hold off submitting to CRAN.

jjallaire commented 3 years ago

As it turns out we can't. manage the jquery conflict w/ distill using htmlDependency (because Distlll site navigation HTML is applied textually outside of the main render). Things should still work fine though. Let's still hold off on CRAN pending @apreshill trying this out as it's possible we'll need additional tweaks to make it work well.

apreshill commented 3 years ago

Hi! Installing from main, when I attempt to knit a postcards output format from template, I'm seeing this error:

Error in rmarkdown::html_document(theme = NULL, self_contained = self_contained,  : 
  argument "css" is missing, with no default
Calls: <Anonymous> ... do.call -> <Anonymous> -> get_template -> <Anonymous>
Execution halted

I'm seeing this both for a doc within a distill site and within a standalone project (🙀 ): https://github.com/apreshill/test-trestles

jjallaire commented 3 years ago

Yikes! My bad. Should be fixed w/ this: https://github.com/seankross/postcards/pull/19