Copy content from archetype
authorbep <bjorn.erik.pedersen@gmail.com>
Sun, 12 Oct 2014 13:57:00 +0000 (15:57 +0200)
committerspf13 <steve.francia@gmail.com>
Wed, 15 Oct 2014 16:40:12 +0000 (12:40 -0400)
Prior to this commit only metadata were copied from archetype on content creation.

This commit includes the content if set in archetype. This is useful in situations with similar page structure.

Fixes #556

create/content.go

index 95bccb01ec61c66ca406af2dac40559f0b224d04..449d63b85d7ea17a6376fb7d93be944bcb1882d6 100644 (file)
@@ -34,7 +34,7 @@ func NewContent(kind, name string) (err error) {
 
        location := FindArchetype(kind)
 
-       var by []byte
+       var by []byte
 
        if location != "" {
                by, err = ioutil.ReadFile(location)
@@ -96,7 +96,7 @@ func NewContent(kind, name string) (err error) {
 
        page.Dir = viper.GetString("sourceDir")
        page.SetSourceMetaData(newmetadata, parser.FormatToLeadRune(viper.GetString("MetaDataFormat")))
-
+       page.SetSourceContent(psr.Content())
        if err = page.SafeSaveSourceAs(path.Join(viper.GetString("contentDir"), name)); err != nil {
                return
        }
@@ -119,7 +119,7 @@ func FindArchetype(kind string) (outpath string) {
 
        for _, x := range search {
                // If the new content isn't in a subdirectory, kind == "".
-               // Therefore it should be excluded otherwise `is a directory` 
+               // Therefore it should be excluded otherwise `is a directory`
                // error will occur. github.com/spf13/hugo/issues/411
                var pathsToCheck []string