Skip to content

Commit

Permalink
move the _files and _cache folders and pause for 2 seconds *before* w…
Browse files Browse the repository at this point in the history
…riting the output file, so that Hugo knows that the very last changed file is the post source file, and the auto-navigation will work much more reliably
  • Loading branch information
yihui committed Oct 9, 2020
1 parent f60b530 commit d7a3df8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 0.20.20
Version: 0.20.21
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Beilei", "Bian", role = "ctb"),
Expand Down
22 changes: 11 additions & 11 deletions R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,21 @@ build_rmds = function(files) {
if (file.copy(shared_yml, copy)) copied_yaml <<- c(copied_yaml, copy)
}

out = NULL
for (f in files) {
d = dirname(f)
out = output_file(f, to_md <- is_rmarkdown(f))
for (i in seq_along(files)) {
f = files[i]; d = dirname(f); out = output_file(f, to_md <- is_rmarkdown(f))
copy_output_yml(d)
message('Rendering ', f, '... ', appendLF = FALSE)
render_page(f)
x = read_utf8(out)
x = encode_paths(x, by_products(f, '_files'), d, base, to_md)
x = encode_paths(x, lib1[2 * i - 1], d, base, to_md)
move_files(lib1[2 * i - 0:1], lib2[2 * i - 0:1])

# when serving the site, pause for a moment so Hugo server's auto navigation
# can navigate to the output page
if ((length(opts$get('served_dirs')) || isTRUE(opts$get('render_one')))) {
Sys.sleep(getOption('blogdown.build_rmds.wait', 2))
}

if (to_md) {
write_utf8(x, out)
} else {
Expand All @@ -142,12 +148,6 @@ build_rmds = function(files) {
append(s, 'draft: yes', 1)
})
}
# when serving the site, pause for a moment so Hugo server's auto navigation
# can navigate to the `out` page
if (!is.null(out) && (length(opts$get('served_dirs')) || isTRUE(opts$get('render_one')))) {
Sys.sleep(getOption('blogdown.build_rmds.wait', 2))
xfun::process_file(out)
}
message('Done.')
}
}
Expand Down

0 comments on commit d7a3df8

Please sign in to comment.