-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding article with links to old website versions (#2190)
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ | |
^staged_dependencies.yaml$ | ||
^inst/dev_dependencies.R$ | ||
^\.devcontainer$ | ||
^vignettes/articles$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,4 @@ Suggests: | |
tibble | ||
VignetteBuilder: knitr | ||
Config/testthat/edition: 3 | ||
Config/Needs/website: gert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.html | ||
*.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: "Previous Versions of Website" | ||
--- | ||
|
||
```{r, include = FALSE} | ||
# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE | ||
# Config/Needs/website: gert | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup, include=FALSE} | ||
base_url <- | ||
"https://pharmaverse.github.io/admiral/" # include the trailing backslash! | ||
# get list of all files in the `gh-pages` branch | ||
df_all_files <- gert::git_ls(ref = "gh-pages") | ||
# extract all folders in the root of the branch | ||
all_folders <- | ||
sub("/.*", "", df_all_files$path)[grepl( | ||
x = df_all_files$path, | ||
pattern = "/", | ||
fixed = TRUE | ||
)] |> | ||
unique() | ||
# subset to all version folders | ||
all_version_folders <- all_folders[grep("^v[0-9]+", x = all_folders)] | ||
# release dates of prior tags | ||
df_tags <- gert::git_tag_list() | ||
df_tags <- df_tags[df_tags$name %in% all_version_folders, ] | ||
df_tags$date <- | ||
lapply( | ||
df_tags$commit, | ||
FUN = function(x) { | ||
tryCatch( | ||
gert::git_commit_info(ref = x)$time |> as.Date() |> as.character(), | ||
error = function(x) NA | ||
) | ||
} | ||
) |> | ||
unlist() | ||
df_tags <- df_tags[!is.na(df_tags$date), ] | ||
df_tags | ||
lst_tag_dates <- | ||
paste0(" (", df_tags$date, ")") |> | ||
as.list() |> | ||
setNames(df_tags$name) | ||
# string with all markdown links | ||
str_website_links <- | ||
lapply( | ||
X = all_version_folders |> rev(), | ||
FUN = function(x) { | ||
paste0("[", x, lst_tag_dates[[x]], "](", paste0(base_url, x), ")") | ||
} | ||
) |> | ||
unlist() |> | ||
paste(collapse = "\n\n") | ||
``` | ||
|
||
`r str_website_links` |