Skip to content

Instantly share code, notes, and snippets.

@simonschoe
Last active February 12, 2021 08:31
Show Gist options
  • Save simonschoe/d83387bcd228ba6352854f9a032e577a to your computer and use it in GitHub Desktop.
Save simonschoe/d83387bcd228ba6352854f9a032e577a to your computer and use it in GitHub Desktop.
Create sharecard of xaringan title slide for sharing
# taken from: https://www.garrickadenbuie.com/blog/sharing-xaringan-slides/
screenshot_share_image <- function(
slides_rmd,
path_image = "share-card.png"
) {
if (!requireNamespace("webshot2", quietly = TRUE)) {
stop(
"`webshot2` is required: ",
'remotes::install_github("rstudio/webshot2")'
)
}
webshot2::rmdshot(
doc = slides_rmd,
file = path_image,
vheight = 600,
vwidth = 600 * 191 / 100,
rmd_args = list(
output_options = list(
nature = list(ratio = "191:100"),
self_contained = TRUE
)
)
)
path_image
}
screenshot_share_image("index.Rmd", path_image = "img/share-card.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment