Skip to content
Permalink
Browse files

fix #414: indicate if an archetype is a page bundle archetype in the …

…"New Post" addin; if it is, add a trailing slash, so I know the actual post to be created is `dir/index.md` but only pass `dir/` to `hugo new`
  • Loading branch information
yihui committed Nov 13, 2019
1 parent 0f66552 commit a93ae13155050d76ab8eaae62f31d32e6471bc07
Showing with 14 additions and 3 deletions.
  1. +1 −1 DESCRIPTION
  2. +3 −0 NEWS.md
  3. +8 −1 R/hugo.R
  4. +2 −1 inst/scripts/new_post.R
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 0.16.1
Version: 0.16.2
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"),
@@ -1,5 +1,8 @@
# CHANGES IN blogdown VERSION 0.17

## BUG FIXES

- The "New Post" addin in RStudio works with page bundle archetypes now (thanks, @malcolmbarrett and @apreshill, #414).

# CHANGES IN blogdown VERSION 0.16

@@ -232,7 +232,9 @@ install_theme = function(


#' @param path The path to the new file under the \file{content} directory.
#' @param kind The content type to create.
#' @param kind The content type to create, i.e., the Hugo archetype. If the
#' archetype is a page bundle archetype, it should end with a slash, e.g.,
#' \code{post/}.
#' @param open Whether to open the new file after creating it. By default, it is
#' opened in an interactive R session.
#' @export
@@ -243,6 +245,11 @@ new_content = function(path, kind = '', open = interactive()) {
path2 = with_ext(path, '.md')
file = content_file(path)
file2 = content_file(path2)
if (grepl('/$', kind)) {
file2 = file.path(dirname(file2), 'index.md')
path2 = dirname(path2)
kind = sub('/$', '', kind)
}
hugo_cmd(c('new', shQuote(path2), if (kind != '') c('-k', kind)))
hugo_toYAML(file2)
file.rename(file2, file)
@@ -9,6 +9,7 @@ xfun::in_dir(blogdown:::site_root(), local({
adir = blogdown:::theme_flag()
adir = if (length(adir) == 4) file.path(adir[2], adir[4], 'archetypes')
adir = c('archetypes', adir)
suff = ifelse(utils::file_test('-d', dir(adir, full.names = TRUE)), '/', '')
shiny::runGadget(
miniUI::miniPage(miniUI::miniContentPanel(
txt_input('title', 'Title', placeholder = 'Post Title'),
@@ -26,7 +27,7 @@ xfun::in_dir(blogdown:::site_root(), local({
sel_input('tag', 'Tags', meta$tags),
shiny::selectInput(
'kind', 'Archetype', width = '98%',
choices = unique(c('', xfun::sans_ext(dir(adir))))
choices = unique(c('', xfun::sans_ext(paste0(dir(adir), suff))))
),
height = '70px'
),

0 comments on commit a93ae13

Please sign in to comment.
You can’t perform that action at this time.