https://github.com/cran/pkgdown
Raw File
Tip revision: 74b598025322cd572dcd58326f0c5fb465f503ab authored by Hadley Wickham on 23 June 2022, 13:00:02 UTC
version 2.0.5
Tip revision: 74b5980
build-logo.R
copy_logo <- function(pkg = ".") {
  pkg <- as_pkgdown(pkg)

  logo_path <- find_logo(pkg$src_path)
  if (!is.null(logo_path)) {
    file_copy_to(pkg, logo_path, from_dir = path_dir(logo_path))
  }
}

find_logo <- function(path) {
  path_first_existing(
    c(
      path(path, "logo.svg"),
      path(path, "man", "figures", "logo.svg"),
      path(path, "logo.png"),
      path(path, "man", "figures", "logo.png")
    )
  )
}

has_logo <- function(pkg) {
  logo_path <- find_logo(pkg$src_path)
  !is.null(logo_path)
}

logo_path <- function(pkg, depth) {
  path <- find_logo(pkg$src_path)
  if (is.null(path)) {
    return()
  }

  paste0(up_path(depth), fs::path_file(path))
}
back to top