rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 334 forks source link

Blogdown with a mix of html_document & flex_dashboard #491

Closed Lion666 closed 3 years ago

Lion666 commented 4 years ago

I built a blogdown site using Hugo and it has multiple sections, posts all written in Rmarkdown with outputs designed as html_document. It works fine.

In parallel, I designed an HTML dashboard using Rmarkdown with an output designed as flex_dashboard. It generates an HTML file working fine.

I wanted to integrate the dashboard directly within the building of the site but unfortunately by simply adding the Rmarkdown file in the blogdown structure it knits it as an html document and not as a flex_dashboard. So, I have the content within my website but not at all as dashboard but more like a traditional html_document. So no luck with that :(

I tried then copying the dashboard html under /static/html and create a brand new Rmarkdown just invoking my html within an iframe:


--- 
output: html_document
---
<link rel="preload" href="/html/OpenDashboard.html" as="document">
<iframe width="100%" height="600" name="iframe" src="/html/OpenDashboard.html"></iframe>

Looked good to me and was pretty happy even in inelegant but performance is bad. It takes a long time to load (+10sec) even if the file is not that big (only 6Mb). Size of the html will grow a lot in the future and I can't hope viewers will wait that long.

I read it was possible to clarify the type of knitting we want within a build.R file but I am clueless on how to specify I want html_document knitting for some Rmarkdowns and flex_dashboard for some others.

For info, the website is www.opensourcepv.com and the dashboard in integrated using an iframe under https://www.opensourcepv.com/opendashboard/

yihui commented 4 years ago

Please read and follow the issue guide exactly to provide all the required information. As requested, please do not ignore or delete the issue guide in your issue, otherwise it is usually hard for us to help you. The issue guide also asked you to mention cross-posting if your cross-posted elsewhere: https://stackoverflow.com/q/64302515/559676 Thanks!

FWIW, your page loads pretty quickly on my computer (one or two seconds).

I read it was possible to clarify the type of knitting we want within a build.R file but I am clueless on how to specify I want html_document knitting for some Rmarkdowns and flex_dashboard for some others.

I've posted an answer on SO.