-
Notifications
You must be signed in to change notification settings - Fork 0
/
investigators.qmd
69 lines (54 loc) · 1.53 KB
/
investigators.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: "Investigators"
---
```{r, echo = FALSE, include = FALSE}
library(yaml)
library(tidyverse)
library(here)
source(here("funs.R"))
# Read info and set links to include
proj_yml <- read_yaml(here("projects.yml"))
athr_yml <- read_yaml(here("authors.yml"))
lnk_cls <- "{.link-box}"
# Only include authors with a bio and a project listed in projects.yml
projs <- names(proj_yml)
athr_yml <- athr_yml %>%
keep(~ {
!is.null(.x$project) &&
any(.x$project %in% projs) &&
!is.null(.x$bio)
})
# Set project links
proj_lnks <- proj_yml %>%
imap(~ .create_project_link(.x$title, str_to_title(.y), "{.link-box-fade}"))
# Create page text
# unable to include table of contents and have the image inline with heading
text <- athr_yml %>%
imap(~ {
lnks <- .x$links %>% # links to project pages
imap(~ str_c(.add_link_icon(.y), "(", .x, ")", lnk_cls)) %>%
str_c(collapse = " ")
lnks <- proj_lnks[.x$project] %>%
str_c(collapse = " ") %>%
str_c(lnks, " ", .)
sfx <- ""
if (!is.null(.x$suffix)) sfx <- str_c(", ", .x$suffix)
res <- str_c(
"<h2>", .y, sfx, "</h2>\n\n",
lnks, "\n\n",
.x$bio, "\n\n"
)
# Add image for each investigator
if (!is.null(.x$image)) {
img <- str_remove(.x$image, here())
html_head <- str_c(
"<div class='investigator-image'>\n",
" <img src='", img, "'>\n"
)
res <- str_c(html_head, res, "</div>\n\n")
}
res
}) %>%
str_c(collapse = "")
```
`r text`