Skip to content

Commit

Permalink
Resolve issues about archetypes and new posts with a non-default `kin…
Browse files Browse the repository at this point in the history
…d` (#263)

* v0.5.5 -- resolves #173

Details: default_kind() now finds the archetype matching the type of content. The new_post addin now lets you choose an archetype.

* v0.5.6 new_content() can now work with files that end in .Rmd and .Rmarkdown. Resolves #261.

Details: new_content() will create a copy of the file with a .md termination so that hugo will be able to work with it. Once hugo is done, the temporary files are deleted.

* Add @lcolladotor as a ctb

* Fix  menu location to keep height at 500 px

* No longer assume that the path includes /content/ for default_kind()

* Remove the big if() {} else {} code. However some if()s are still needed in case that the file does indeed have a .md file extension (otherwise it gets deleted). Hopefully this look less complicated

* Switch to code @yihui wrote in the PR review (after testing it)

* Switch back to original code for default_kind() now that I understand correctly that path is post/date-slug.md or something like that instead of content/post/date-slug.md
  • Loading branch information
lcolladotor authored and yihui committed Feb 27, 2018
1 parent 95f694d commit c2f14cc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 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.5.4
Version: 0.5.6
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 All @@ -10,6 +10,7 @@ Authors@R: c(
person("Ian", "Lyttle", role = "ctb"),
person("JJ", "Allaire", role = "ctb"),
person("Kevin", "Ushey", role = "ctb"),
person("Leonardo", "Collado-Torres", role = "ctb"),
person(family = "RStudio Inc", role = "cph"),
person()
)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- Added a `hostname` argument to `install_theme()` and `new_site()`, as a complement to the `theme` argument. The default `hostname` is `'github.com'`; if you have access to GitHub Enterprise, you can use this to specify it instead (thanks, @ijlyttle, #264).

- The `new_post` addin now lets you choose an archetype. See https://gohugo.io/content-management/archetypes/ for more details (thanks, @lcolladotor, #173).

## BUG FIXES

- `new_content()` now works with files that end in .Rmd and .Rmarkdown. The archetype still has to end in .md for hugo to work with it (thanks, @lcolladotor, #261).

# CHANGES IN blogdown VERSION 0.5

## BUG FIXES
Expand Down
9 changes: 6 additions & 3 deletions R/hugo.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ install_theme = function(
#' (e.g. a post or a page).
new_content = function(path, kind = 'default', open = interactive()) {
if (missing(kind)) kind = default_kind(path)
hugo_cmd(c('new', shQuote(path), c('-k', kind)))
file = content_file(path)
hugo_toYAML(file)
path2 = with_ext(path, '.md')
file = content_file(path)
file2 = content_file(path2)
hugo_cmd(c('new', shQuote(path2), c('-k', kind)))
hugo_toYAML(file2)
file.rename(file2, file)
if (open) open_file(file)
file
}
Expand Down
6 changes: 5 additions & 1 deletion inst/scripts/new_post.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ local({
shiny::fillRow(
sel_input('cat', 'Categories', meta$categories),
sel_input('tag', 'Tags', meta$tags),
shiny::selectInput(inputId = 'kind', label = 'Archetype',
choices = c('default', gsub('.md', '', dir('archetypes',
pattern = '\\.md$')))),
height = '70px'
),
shiny::fillRow(
Expand Down Expand Up @@ -66,7 +69,8 @@ local({
input$title, author = input$author, ext = input$format,
categories = input$cat, tags = input$tag,
file = gsub('[-[:space:]]+', '-', input$file),
slug = input$slug, subdir = input$subdir, date = input$date
slug = input$slug, subdir = input$subdir, date = input$date,
kind = input$kind
)
shiny::stopApp()
})
Expand Down

0 comments on commit c2f14cc

Please sign in to comment.