R/build-logo.R

Defines functions build_logo find_logo

 <- function(pkg = ".", path = "docs/") {
  pkg <- as_pkgdown(pkg)
  path <- rel_path(path, pkg$path)

  logo_path <- (pkg$path)
  if (is.null(logo_path))
    return()

  if (!requireNamespace("magick", quietly = TRUE)) {
    message("Magick not avaliable, not creating favicon.ico")
    return()
  }
  message("Copying logo")
  file.copy(logo_path, file.path(path, "logo.png"))

  message("Creating favicon")
  magick::image_read(logo_path) %>%
	  magick::image_scale("32x32") %>%
	  magick::image_write(file.path(path, "favicon.ico"), format = "png")
}


 <- function(path) {
  logo_path <- file.path(path, "logo.png")
  if (file.exists(logo_path))
    return(logo_path)

  logo_path <- file.path(path, "man", "figures", "logo.png")
  if (file.exists(logo_path))
    return(logo_path)

  NULL
}
Laurae2/pkgdown documentation built on May 27, 2019, 12:17 p.m.