Skip to content

Instantly share code, notes, and snippets.

@kleinlennart
Last active March 12, 2021 18:25
Show Gist options
  • Save kleinlennart/e16c13d816b96c7d9eb077c31c979f95 to your computer and use it in GitHub Desktop.
Save kleinlennart/e16c13d816b96c7d9eb077c31c979f95 to your computer and use it in GitHub Desktop.
Drake flavoured `render_site()` page build routine with static branching
# needs to be outside of the drake plan for `rmd_files = !!pages_paths` to work
pages_paths <- dir("reports", pattern = "*.Rmd", full.names = TRUE)
# TODO: exclude _file.Rmd with regex in dir
plan <- drake_plan(
render_pages = target(
# TODO: Add a trigger dependency on _site.yml
command = rmarkdown::render(
knitr_in(rmd_files),
output_dir = file_out("docs/"),
quiet = TRUE
),
transform = map(rmd_files = !!pages_paths)
# “bang-bang” operator !! from tidy evaluation
)
)
# not quite sure about the site_libs dir of render_site()...
# CSS, yml tags and assets work fine though
# Inspired by: https://rdrr.io/github/webbedfeet/coursedown/src/inst/templates/_drake.R
@kleinlennart
Copy link
Author

kleinlennart commented Sep 29, 2020

@conradborchers See page wise render routine here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment