#' Write freeform
#'
#' Produce file content and filenames for a daily and monthly freeform journal
#'
#' @param date_start date to start journal on - must be the first day of a month
#' @param date_end date to end journal on - must be the last day of a month
#' @return A tibble with two variables: a vector of markdown file contents and a vector of filenames
#' @importFrom rlang .data
#' @importFrom magrittr %>%
#' @export
journal_freeform <- function(date_start, date_end){
# Defaults
filename_body <- "freeform.md"
# Allow both weekly and monthly for freeform
template_tibble <- new_journalr_tbl_df(date_start, "month", date_end)
# Freeform-specific ----
daily_content <- template_tibble %>%
dplyr::mutate(
file_contents = paste0(
"# ", .data$titlename, "\n\n",
purrr::map_chr(.data$date_vec, ~paste(
glue::glue("## {.x}\n\n* \n\n"), collapse = "\n"
))
)
)
# Periodic contents
period_body <- paste("##", daily_content$titlename, "\n\n* \n\n") %>%
stringr::str_c(collapse = "\n")
period_title <- paste("Monthly reflections:",
format_date_to_date(date_start, date_end, format_date_mon))
period_contents <- period_body %>%
add_h1_title(period_title)
# Combine
daily_out <- daily_content %>%
add_files_template_tibble("month", filename_body) %>%
dplyr::select(.data$file_contents, .data$filename)
period_out <- tibble::tibble(
file_contents = period_contents,
filename = paste0("monthly_", filename_body)
)
dplyr::bind_rows(daily_out, period_out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.