load_notes <- function(dir) {
basic_files <- list.files(dir, pattern = ".*\\.(r)?md", full.names = TRUE,
ignore.case = TRUE)
file_content <- headers <- vector(mode = "list", length = length(basic_files))
for (k in seq_along(basic_files)) {
headers[[k]] <- rmarkdown::yaml_front_matter(basic_files[k])
file_content[[k]] <- markdown_content(basic_files[k])
}
tibble::tibble(file = basic_files, as.data.frame(headers), contents = file_content)
}
markdown_content <- function(file) {
content <- readLines(file)
delimiters <- grep(pattern = "^(---|\\{3})\\s*$", content)
if (length(delimiters) %% 2L) {
stop("File ", file, " has an uneven number of yaml front-matter delimiters, \"---\" or \"...\".",
" It must have exactly 2", call. = FALSE)
}
content[-(delimiters[1]:delimiters[2])]
}
ln <- load_notes("jotdown")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.