Repository navigation
Expand file tree
/
Copy pathsetup.R
More file actions
62 lines (52 loc) · 1.35 KB
/
Copy pathsetup.R
File metadata and controls
62 lines (52 loc) · 1.35 KB
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
# libraries ----
if (!require("librarian")){
install.packages("librarian")
}
shelf(
bslib,
dplyr,
fs,
glue,
htmltools,
knitr,
purrr,
rmarkdown,
quiet = T)
# functions ----
param_icons <- icons <- c(
website = "link",
details = "info-circle",
code = "github",
video = "youtube")
param_html <- function(param){
if (!param %in% names(fm$params))
return("")
icon <- param_icons[[param]]
val <- fm$params[[param]]
glue('<i class="fa fa-{icon}"></i> <a href="{val}">{param}</a> ')
}
get_cards <- function(tech = NULL, node = NULL){
Rmds <- d_Rmd %>% pull(Rmd)
if (!is.null(tech))
Rmds <- d_Rmd %>% filter(tech == !!tech) %>% pull(Rmd)
if (!is.null(node))
Rmds <- d_Rmd %>% filter(nodes == !!node) %>% pull(Rmd)
src = lapply(Rmds, function(Rmd) { # Rmd = Rmds[1]
knitr::knit_expand('_card.Rmd')
})
res = knitr::knit_child(text = unlist(src), quiet = TRUE)
cat(res, sep = '\n')
}
# TODO: Last updated: get from Github API
# products ----
d_Rmd <- tibble(
Rmd = list.files(pattern="^p_.*\\.Rmd$"),
fm = map(Rmd, yaml_front_matter),
tech = map_chr(fm, function(fm) fm$params$tech),
nodes = map_chr(fm, function(fm) fm$params$nodes))
knit_Rmd <- current_input()
if (knit_Rmd %in% d_Rmd$Rmd){
fm <- yaml_front_matter(knit_Rmd)
}
# rmd ----
tagList(html_dependency_font_awesome())