diff --git a/R/coursera.R b/R/coursera.R index 920fb22..46b7669 100644 --- a/R/coursera.R +++ b/R/coursera.R @@ -295,15 +295,30 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"), # Retrieve yaml file specs output_yaml_lines <- yaml::yaml.load_file(output_yaml_file) - # Copy over css file that's specified + # Copy over css file(s) that's specified org_css_file <- output_yaml_lines$`bookdown::gitbook`$css - css_file <- file.path(output_dir, org_css_file) - - # Write it as "style.css" - fs::file_copy(org_css_file, - css_file, - overwrite = TRUE - ) + + # Check if there are multiple .css + if(length(org_css_file) > 1){ + # Read all .css + css_files_read <- sapply(org_css_file, readLines) + + # Make a "mega .css" and write + if (verbose) { + message("Combining .css files") + } + css_lines_cat <- rbind(unlist(css_files_read)) + css_file <- file.path(output_dir, org_css_file[1]) + writeLines(css_lines_cat, css_file) + } else { + css_file <- file.path(output_dir, org_css_file) + + # Write it as "style.css" + fs::file_copy(org_css_file, + css_file, + overwrite = TRUE + ) + } ###### Now do the rendering! ###### message("Render bookdown without TOC") @@ -312,8 +327,7 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"), bookdown::render_book( input = "index.Rmd", output_yaml = output_yaml_file, - output_dir = output_dir, - clean_envir = FALSE + output_dir = output_dir ) # Read in TOC closing CSS lines