From ef9468e02378eace43a4d4f437159ba0dcdf2144 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Wed, 3 Feb 2021 14:08:54 -0600 Subject: [PATCH] fix #577: when creating new posts from bundle archetypes, the actual file path is path/index.md instead of path/ --- NEWS.md | 2 ++ R/hugo.R | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index 2537b62b..07bf7250 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,8 @@ - For `.Rmarkdown` posts, the Markdown extension `tex_math_dollars` should not be used when post-processing the `.markdown` output file with Pandoc < v2.10.1 (thanks, @lz100, #578). +- The `new_post()` function does not work with bundle archetypes (thanks, @maelle, #577). + ## MINOR CHANGES - When clicking the Knit button in RStudio to knit a post, the normal knitting process is shown (such as the progress bar) instead of being suppressed (thanks, @Athanasiamo, #572). diff --git a/R/hugo.R b/R/hugo.R index 683b3095..38a9cda3 100644 --- a/R/hugo.R +++ b/R/hugo.R @@ -458,6 +458,9 @@ download_modules = function(mod) { new_content = function(path, kind = '', open = interactive()) { if (missing(kind)) kind = default_kind(path) path2 = with_ext(path, '.md') + # for a new content file to be created with a bundle archetype, its path + # should not contain index.md but only the dir name, otherwise the archetype + # will not be used if (grepl('/$', kind)) { path2 = dirname(path2) kind = sub('/$', '', kind) @@ -469,6 +472,7 @@ new_content = function(path, kind = '', open = interactive()) { ) if (length(i <- grep(r <- ' created$', file2)) == 1) { file2 = sub(r, '', file2[i]) + if (!grepl('[.]md$', file2)) file2 = file.path(file2, 'index.md') } else { # should the above method fail to identify the newly created .md, search for # the new file with brute force