mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-23 19:21:26 +00:00
create: Simplify archetype logic
See ##2750
This commit is contained in:
parent
96018ab98c
commit
b2eadd93d3
1 changed files with 3 additions and 12 deletions
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue