fix issue 411, /path/to/site/archetypes : is a directory error

This commit is contained in:
Joel Scoble 2014-08-18 19:52:43 -05:00 committed by spf13
parent e31d460909
commit cece27fa2e

View file

@ -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
}
}