R/use_content.R

Defines functions use_content

Documented in use_content

#' use_content
#'
#' Adds content to the specified directory.
#'
#' @param content A character string for the name of the content. The
#'   only options are "header image" and "urban logo".
#'
#' @md
#' @export
use_content <- function(content) {

  if (content == "header image") {

    if (!dir.exists("www")) {
      dir.create("www")
    }

    if (!dir.exists("www/images")) {
      dir.create("www/images")
    }

    img_data <- magick::image_read(system.file("content/urban-institute-logo.png", package = "urbntemplates"))

    magick::image_write(img_data, "www/images/urban-institute-logo.png")

  }  else if (content == "urban logo") {

    if (!dir.exists("design")) {

      dir.create("design")

    }

    img_data <- magick::image_read(system.file("content/urban_grid_blue_white.jpg", package = "urbntemplates"))

    magick::image_write(img_data, "design/urban_grid_blue_white.jpg")

  } else {

    stop("Invalid 'preamble' argument. Valid stylesheets are: ",
         "fact_sheet",
         call. = FALSE)

  }
}
UrbanInstitute/urbntemplates documentation built on April 27, 2022, 4:35 a.m.