Hi @howardm19. If I got your question right, you are looking for a way to automate the creation of the page. I write a function that read your list directories under a subdir of _post and create a yaml file serves as a new listing page. Every time you update any chapters in the folder, you should just run the function and it will recreate the file. Here is the code:
create_new_listing <- function(title = "My title", subfolder = "Gallery"){
override <- T
if(file.exists(here::here(paste0(subfolder, ".Rmd")))){
usethis::ui_info("File exists, override?")
override <- utils::menu(choices = c("Yes", "No")) == 1
}
if(override){
write_yml <- function(what){
write(what, file = here::here(glue::glue("{subfolder}.Rmd")), append = TRUE)
}
file.create(here::here(paste0(subfolder, ".Rmd")))
write_yml("---")
write_yml(glue::glue("title: {title}"))
write_yml("site: distill::distill_website")
write_yml("listing:")
write_yml(" posts:")
purrr::walk(
list.dirs(here::here(glue::glue("_posts/{subfolder}")), full.names = F, recursive = F),
function(.x){ write_yml(paste0(' - ',subfolder, '/', .x)); cat('\n')}
)
write_yml("---")
} else {
usethis::ui_oops("Your file has not been touched!")
}
}