R/make_talk_md.R

Defines functions make_talk_md

Documented in make_talk_md

#' Make markdown files for talks
#'
#' This function will create markdown files in the Hugo Academic style for talks
#' specified in a Google Sheet.
#'
#' @param dir The directory you would like the markdown documents to be saved in
#' @param id Your Google Sheet id
#' @export
make_talk_md <- function(dir, id = "1-PItelqpv0Sb_LdiEDqb8O3D_Roii5nVTL07IRVbRtA") {
  d <- googlesheets4::range_read(googlesheets4::as_sheets_id(id))
  d <- d[d$manual == 0, ]
  md <- glue::glue_data(d, {
    "+++
## Generated by the R package lazyacademic
## Do not edit directly, edit the Google Sheet [id = (id)]
title = \"(title)\"
event = \"(where)\"
time_start = (start)
time_end = (end)

abstract = \"(abstract)\"
url_custom = [{name = \"Link\", url = \"(link)\"}]
+++
"
  }, .open = "(", .close = ")")
  file_base <- tolower(gsub(" ", "_", d$where))
  file_name <- glue::glue("{dir}/{file_base}.md")
  purrr::walk2(md, file_name, writeLines)
}
LucyMcGowan/lazyacademic documentation built on May 20, 2020, 2:50 a.m.