Skip to content

Commit

Permalink
fix #577: when creating new posts from bundle archetypes, the actual …
Browse files Browse the repository at this point in the history
…file path is path/index.md instead of path/
  • Loading branch information
yihui committed Feb 3, 2021
1 parent 46e0b3c commit ef9468e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions R/hugo.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit ef9468e

Please sign in to comment.