Skip to content

Commit

Permalink
Fix issue w/ duplicate includes within website articles
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Jan 3, 2021
1 parent cc20d87 commit 0f03ee6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions R/distill_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {

Expand All @@ -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()

Expand Down Expand Up @@ -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))
Expand All @@ -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() {
Expand Down

5 comments on commit 0f03ee6

@julianbarg
Copy link

@julianbarg julianbarg commented on 0f03ee6 Jan 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something in this commit yields an error when trying to build my website. No problems after reverting to previous commit. Error message is:

Error in metadata[["output"]][["distill::distill_article"]] :
  subscript out of bounds
Calls: <Anonymous> ... <Anonymous> -> call_post_knit_handler -> <Anonymous> -> overlay
Execution halted

Exited with status 1.

@jjallaire
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I just backed that. Will revisit again later today. Could you send a link to you site's repo so I can try out locally?

@julianbarg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjallaire
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks! Should be all set on master now, let me know if you see additional problems.

@julianbarg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem now, thanks!

Please sign in to comment.