diff --git a/DESCRIPTION b/DESCRIPTION index 440f3a9c..e76e733a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: blogdown Type: Package Title: Create Blogs and Websites with R Markdown -Version: 0.20.17 +Version: 0.20.18 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person("Beilei", "Bian", role = "ctb"), diff --git a/R/render.R b/R/render.R index a799dc68..b51b1b60 100644 --- a/R/render.R +++ b/R/render.R @@ -97,8 +97,8 @@ timestamp_filter = function(files) { files[require_rebuild(output_file(files), files)] } -# raw indicates paths of dependencies are not encoded in the HTML output -build_rmds = function(files) { +# build R Markdown posts +build_rmds = function(files, pause = FALSE) { if (length(files) == 0) return() # ignore files that are locked (being rendered by another process) i = !file.exists(locks <- paste0(files, '.lock~')) @@ -134,6 +134,7 @@ 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)) @@ -152,6 +153,12 @@ build_rmds = function(files) { append(s, 'draft: yes', 1) }) } + # when serving the site, pause for a moment so Hugu server's auto navigation + # can navigate to the `out` page + if (pause || (!is.null(out) && length(opts$get('served_dirs')))) { + Sys.sleep(getOption('blogdown.build_rmds.wait', 2)) + xfun::process_file(out) + } message('Done.') } } diff --git a/R/site.R b/R/site.R index c83a9365..b6a79fc1 100644 --- a/R/site.R +++ b/R/site.R @@ -13,7 +13,7 @@ blogdown_site = function(input, ...) { # rendering a single file (by clicking the Knit button) if (!is.null(input_file)) xfun::in_dir(site_root(), { input_file = rmarkdown::relative_to(getwd(), input_file) - build_rmds(input_file) + build_rmds(input_file, pause = TRUE) # run serve_site() to preview the site if the server has not been started if (interactive()) preview_site() else tryCatch( rstudioapi::sendToConsole('blogdown:::preview_site()', echo = FALSE)