# Enables Font Awesome in HTML based bookdown outputs. fa <- rmarkdown::html_dependency_font_awesome() fa$attachment <- "fonts/fontawesome-webfont.ttf" htmltools::tagList(fa) knitr::opts_chunk$set(echo = FALSE)
library(tidyverse) library(fs) library(glue) library(kableExtra) parse_title <- function(f){ if(is.na(f)) return(NA) rmarkdown::yaml_front_matter(f)$title } setwd(here::here('docs','slides')) htmls <- dir_ls('lectures',regex = '\\d{2}.*html') pdfs <- dir_ls('lectures', regex = '\\d{2}.*pdf') rmds <- dir_ls('lectures', regex = '\\d{2}.*.Rmd') htmls <- tibble(HTML = htmls) %>% mutate(base = path_file(HTML) %>% str_replace('.html','')) pdfs <- tibble(PDF = pdfs) %>% mutate(base = path_file(PDF) %>% str_replace('.pdf','')) rmds <- tibble(Rmd = rmds) %>% mutate(base = path_file(Rmd) %>% str_replace('.Rmd','')) blah <- Reduce(full_join, list(htmls, pdfs,rmds)) %>% select(base, everything()) blah <- blah %>% tidyr::gather(variable, value, -base) %>% mutate(value = glue('[{variable}]({value}){{target="_blank"}}')) %>% mutate(value = ifelse(str_detect(value, 'NA'), '', value)) %>% spread(variable, value) %>% rename(Lecture=base) %>% mutate(Lecture = Lecture %>% str_extract('^\\d+') %>% as.numeric() %>% glue::glue('Lecture {x}', x = .)) %>% mutate(Title = map_chr(str_match(Rmd, '\\((.+)\\)')[,2],parse_title)) %>% select(Lecture, Title, everything()) %>% mutate_all(~ifelse(is.na(.), '', .)) kable(blah) %>% kable_styling(bootstrap_options='striped', full_width = T) setwd(here::here())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.