Skip to content

Commit

Permalink
allow for empty or missing DOI; bump news
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar committed Nov 10, 2023
1 parent 5915f0d commit a8579c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
appended. Note that when clicking these links, the user will remain in
instructor view. This behaviour may change in future iterations (reported:
@karenword, #394; fixed: @ErinBecker, #530, reviewed: @zkamvar)
* DOI badges can now be displayed when paired with {varnish} version 0.4.0 by
adding the `doi:` key to the `config.yaml` file with either the raw DOI or
the URL to the DOI (reported: @tobyhodges, carpentries/workbench#67;
fixed: @tobyhodges, #535).

## BUG FIX

Expand Down
7 changes: 5 additions & 2 deletions R/utils-yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ create_pkgdown_yaml <- function(path) {
handout <- if (is.null(usr$handout)) "~" else usr$handout
handout <- if (isTRUE(handout)) "files/code-handout.R" else handout
yaml <- get_yaml_text(template_pkgdown())
# Should we display DOI info? If so, parse the URL and return the doi
# note that a missing doi will return nothing
doi <- sub("^[/]", "", xml2::url_parse(usr$doi)$path)
doi <- if (length(doi) == 1L && nzchar(doi)) siQuote(doi) else "~"
yaml <- whisker::whisker.render(yaml,
data = list(
# Basic information
Expand All @@ -187,8 +191,7 @@ create_pkgdown_yaml <- function(path) {
alpha = usr$life_cycle == "alpha",
beta = usr$life_cycle == "beta",
stable = usr$life_cycle == "stable",
# Should we display DOI info?
doi = siQuote(usr$doi),
doi = doi,
NULL
)
)
Expand Down

0 comments on commit a8579c7

Please sign in to comment.