From 46e0b3c97bdf6036ec8e46edd29832cea264fac2 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Wed, 3 Feb 2021 14:04:20 -0600 Subject: [PATCH] dir() and dir(full.names = TRUE) can return paths of different orders, e.g., > dir(adir) [1] "default.md" "Rmd" > dir(adir, full.names = TRUE) [1] "archetypes/Rmd" "themes/hugo-lithium/archetypes/default.md" so we need to use dir(full.names = TRUE) and then basename() to get the base filenames, instead of using dir() --- inst/scripts/new_post.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inst/scripts/new_post.R b/inst/scripts/new_post.R index 1be8377f..5b3c2aae 100644 --- a/inst/scripts/new_post.R +++ b/inst/scripts/new_post.R @@ -8,7 +8,9 @@ lang = blogdown:::get_lang() adir = blogdown:::theme_dir() adir = if (length(adir)) file.path(adir, 'archetypes') adir = c('archetypes', adir) -suff = ifelse(utils::file_test('-d', dir(adir, full.names = TRUE)), '/', '') +adir = dir(adir, full.names = TRUE) +adir = paste0(basename(adir), ifelse(utils::file_test('-d', adir), '/', '')) + shiny::runGadget( miniUI::miniPage(miniUI::miniContentPanel( txt_input('title', 'Title', placeholder = 'Post Title'), @@ -28,7 +30,7 @@ shiny::runGadget( sel_input('tag', 'Tags', meta$tags), shiny::selectInput( 'kind', 'Archetype', width = '98%', - choices = unique(c('', xfun::sans_ext(paste0(dir(adir), suff)))) + choices = unique(c('', adir)) ), height = '70px' ),