Skip to content

Instantly share code, notes, and snippets.

@EmilHvitfeldt
Created December 12, 2020 19:39
Show Gist options
  • Save EmilHvitfeldt/eb7896d3df476cb7962cda4c0eeffdb2 to your computer and use it in GitHub Desktop.
Save EmilHvitfeldt/eb7896d3df476cb7962cda4c0eeffdb2 to your computer and use it in GitHub Desktop.
Render files in subdirectories for markdown websites
new_render <- function(dir = "readings") {
old_names <- fs::dir_ls(dir)
new_names <- basename(old_names)
if (any(new_names %in% fs::dir_ls())) {
stop("Files in folders can not have same name as main files")
}
fs::file_move(old_names, new_names)
rmarkdown::render_site()
fs::file_move(new_names, old_names)
}
new_render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment