Skip to content

Commit

Permalink
expand repo links
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaMetori committed Nov 23, 2023
1 parent cedaac9 commit d9669b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
27 changes: 23 additions & 4 deletions R/bs4_book.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,35 @@ tweak_navbar <- function(html, toc, active = "", rmd_index = NULL, repo = NULL)
repo$subdir <- paste0(repo$subdir, "/")
}

repo_edit <- paste0(repo$base, "/edit/", repo$branch, "/", repo$subdir, rmd_index[[active]])
repo_view <- paste0(repo$base, "/blob/", repo$branch, "/", repo$subdir, rmd_index[[active]])
if(grepl("dev.azure", repo$base)) {
repo_edit <- paste0(repo$base, "?path=/", rmd_index[[active]])
repo_view <- repo_edit
} else if(grepl("bitbucket", repo$base)){
repo_edit <- paste0(repo$base, "/browse/", rmd_index[[active]])
repo_view <- repo_edit
} else {
repo_edit <- paste0(repo$base, "/edit/", repo$branch, "/", repo$subdir, rmd_index[[active]])
repo_view <- paste0(repo$base, "/blob/", repo$branch, "/", repo$subdir, rmd_index[[active]])
}

} else {
repo_edit <- NULL
repo_view <- NULL
}

if (!is.null(repo$base)) {
icon <- repo$icon %n%
ifelse(grepl("github\\.com", repo$base), "fab fa-github", "fab fa-gitlab")
icon <- repo$icon %n% {
if(grepl("github\\.com", repo$base)) {
"fab fa-github"
} else if (grepl("dev.azure", repo$base)) {
"fab fa-microsoft"
} else if (grepl("dev.azure", repo$base)) {
"fab fa-bitbucket"
} else {
"fab fa-gitlab"
}
}

template_link_icon(html, ".//a[@id='book-repo']", icon)
template_link_icon(html, ".//a[@id='book-source']", icon)
template_link_icon(html, ".//a[@id='book-edit']", icon)
Expand Down
16 changes: 10 additions & 6 deletions man/publish_book.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9669b1

Please sign in to comment.