diff --git a/NEWS.md b/NEWS.md index 66cbc3e8..765999b5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ - Enhance `create_article()` function to create articles from alternate formats. - Fix issue w/ broken images in search results for pages with no preview image. - Fix issue w/ attempting to add non-site Rmds (e.g. README.Rmd) to search index. +- Fix issue w/ duplicate `includes` within website articles - Suppress citation for individual articles/posts via `citation: false` metadata. ## distill v1.1 (CRAN) diff --git a/R/distill_article.R b/R/distill_article.R index a8d20a8d..60146682 100644 --- a/R/distill_article.R +++ b/R/distill_article.R @@ -114,6 +114,10 @@ distill_article <- function(toc = FALSE, site_config <- NULL encoding <- NULL + # metadata_includes are includes derived from this file's metadata + # (as opposed to site level includes which we already process) + metadata_includes <- list() + # post-knit post_knit <- function(metadata, input_file, runtime, encoding, ...) { @@ -123,6 +127,9 @@ distill_article <- function(toc = FALSE, # run R code in metadata metadata <- eval_metadata(metadata) + # determine metadata_includes + metadata_includes <<- metadata[["output"]][["distill::distill_article"]][["includes"]] + # pandoc args args <- c() @@ -239,11 +246,11 @@ distill_article <- function(toc = FALSE, before_body <- c(front_matter_before_body(metadata), navigation_before_body_file(dirname(input_file), site_config), site_before_body_file(site_config), - includes$before_body, + metadata_includes$before_body, listing$html) # after body includes: user then distill - after_body <- c(includes$after_body, + after_body <- c(metadata_includes$after_body, site_after_body_file(site_config), appendices_after_body_file(input_file, site_config, metadata), navigation_after_body_file(dirname(input_file), site_config)) @@ -263,7 +270,7 @@ distill_article <- function(toc = FALSE, pre_processor <- function(yaml_front_matter, utf8_input, runtime, knit_meta, files_dir, output_dir, ...) { pandoc_include_args(in_header = c(site_in_header_file(site_config), - includes$in_header)) + metadata_includes$in_header)) } on_exit <- function() {