r-lib / pkgdown

Generate static html documentation for an R package
https://pkgdown.r-lib.org/
Other
713 stars 335 forks source link

Should bslib usage happen only once #1695

Closed maelle closed 2 years ago

maelle commented 3 years ago

At the moment, the way data_deps() is called in render_page() mean bslib is called for every page which is extremely wasteful as we do not allow bslib variables in the YAML.

So instead, should data_deps() be memoised? Or should there be more refactoring? data_deps() depends on depth.

maelle commented 3 years ago

In the dark mode draft PR I created create_theme(). https://github.com/r-lib/pkgdown/pull/1707/files#diff-e5b9c825f5f1d14686b4e41fda5e5b36139e75c6c2d571485d96c53dc331c8bdR466 Its arguments are pkg, bootswatch_theme, bs_version, mode. It returns "a sass::sass_bundle() (list-like) object.".

maelle commented 3 years ago

bslib stuff could happen in init_site() :thinking:

maelle commented 3 years ago

A difference between the assets created by bslib and the logo is that there are several files created therefore several paths. Maybe init_site() could store these paths in a text file so that render_page() would read them (and add as many ../ as needed, as done for the logo).

maelle commented 3 years ago

Actually what htmltools::renderDependencies() outputs are the tags to be put in head. I might resort to using regular expressions. :cold_sweat: