summaryrefslogtreecommitdiffstats
path: root/create
diff options
context:
space:
mode:
authorJoel Scoble <joel.scoble@outlook.com>2014-08-18 19:52:43 -0500
committerspf13 <steve.francia@gmail.com>2014-08-19 22:30:21 -0400
commitcece27fa2e5b4c273bb763cefa749ff9b6c46636 (patch)
treeb3963458da0aaff6318944165af24484186c85a2 /create
parente31d4609098f8f9c86551c3d1b11cb887b42bfcb (diff)
fix issue 411, /path/to/site/archetypes : is a directory error
Diffstat (limited to 'create')
-rw-r--r--create/content.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/create/content.go b/create/content.go
index aea84c517..95bccb01e 100644
--- a/create/content.go
+++ b/create/content.go
@@ -30,11 +30,11 @@ import (
)
func NewContent(kind, name string) (err error) {
- jww.INFO.Println("attempting to create", name, "of", kind)
+ jww.INFO.Println("attempting to create ", name, "of", kind)
location := FindArchetype(kind)
- var by []byte
+ var by []byte
if location != "" {
by, err = ioutil.ReadFile(location)
@@ -118,11 +118,21 @@ func FindArchetype(kind string) (outpath string) {
}
for _, x := range search {
- pathsToCheck := []string{kind + ".md", kind, "default.md", "default"}
+ // If the new content isn't in a subdirectory, kind == "".
+ // Therefore it should be excluded otherwise `is a directory`
+ // error will occur. github.com/spf13/hugo/issues/411
+ var pathsToCheck []string
+
+ if kind == "" {
+ pathsToCheck = []string{"default.md", "default"}
+ } else {
+ pathsToCheck = []string{kind + ".md", kind, "default.md", "default"}
+ }
for _, p := range pathsToCheck {
curpath := path.Join(x, p)
jww.DEBUG.Println("checking", curpath, "for archetypes")
if exists, _ := helpers.Exists(curpath); exists {
+ jww.INFO.Println("curpath: " + curpath)
return curpath
}
}