diff options
author | Bjørn Erik Pedersen <[email protected]> | 2016-11-29 20:32:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2016-11-29 20:32:26 +0100 |
commit | b2eadd93d3e8b066c7c1b344078f6ee159603cb3 (patch) | |
tree | bc726d9c042e315bfe9dc788ad42bcfbf362e164 /create | |
parent | 96018ab98c1153c9d882656abf99685f2fb7e0c4 (diff) | |
download | hugo-b2eadd93d3e8b066c7c1b344078f6ee159603cb3.tar.gz hugo-b2eadd93d3e8b066c7c1b344078f6ee159603cb3.zip |
create: Simplify archetype logic
See ##2750
Diffstat (limited to 'create')
-rw-r--r-- | create/content.go | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/create/content.go b/create/content.go index 783e21449..08094f261 100644 --- a/create/content.go +++ b/create/content.go @@ -119,28 +119,19 @@ func createMetadata(archetype parser.Page, name string) (map[string]interface{}, } case "title": // Use the archetype title as is - metadata[lk] = cast.ToString(v) + metadata[lk] = v } } - caseimatch := func(m map[string]interface{}, key string) bool { - for k := range m { - if strings.ToLower(k) == strings.ToLower(key) { - return true - } - } - return false - } - if metadata == nil { metadata = make(map[string]interface{}) } - if !caseimatch(metadata, "date") { + if date.IsZero() { date = time.Now() } - if !caseimatch(metadata, "title") { + if _, ok := metadata["title"]; !ok { metadata["title"] = helpers.MakeTitle(helpers.Filename(name)) } |