ropensci-org / blog-guidance

rOpenSci Blog Guidelines for Authors and Editors (bookdown::git_book)
https://blogguide.ropensci.org/
9 stars 4 forks source link

Guidance embedding HTML widgets #168

Closed wlandau closed 3 years ago

wlandau commented 3 years ago

I am drafting a post that uses visNetwork widgets. Normally, in R Markdown, I just call visNetwork(), and the widget appears in the HTML. But because the site renders differently than a local call to rmarkdown::render() on the Rmd file, the widgets do not appear. I am currently working around this with visNetwork::visSave() (which just calls htmlwidgets::saveWidget()) and an iframe to load the HTML file. This mostly works, but the external HTML files are inconvenient, and the widths and heights were difficult to coordinate between the widget and the iframe.

Is it possible to embed widgets without external files? If so, it would be nice if this were part of the guide.

stefaniebutland commented 3 years ago

Thanks for the feedback @wlandau. @steffilazerte can you please have a look?

steffilazerte commented 3 years ago

@maelle Is this possible? I can add it to the blog guide, but I'm not at all sure about how this works with Hugo.

maelle commented 3 years ago

I think that's the current guidance, to host the interactive things somewhere else?

Instead of using html widgets (DT, leaflet, etc.), include a screenshot and use the link option of the Hugo figure shortcode to direct readers to an online version of the widget.

If I remember correctly, this was after a discussion with @jeroen.