diff --git a/frontmatter/frontmatter.go b/frontmatter/frontmatter.go index 83d8cc06..147715cc 100644 --- a/frontmatter/frontmatter.go +++ b/frontmatter/frontmatter.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/hacdias/caddy-hugo/utils" + "github.com/spf13/cast" "github.com/spf13/hugo/parser" ) @@ -136,11 +137,14 @@ func handleFlatValues(content interface{}, parent *frontmatter, name string) *fr c.Type = "string" } + c.Content = content + switch strings.ToLower(name) { case "description": c.HTMLType = "textarea" case "date", "publishdate": c.HTMLType = "datetime" + c.Content = cast.ToTime(content) default: c.HTMLType = "text" } @@ -159,6 +163,5 @@ func handleFlatValues(content interface{}, parent *frontmatter, name string) *fr log.Panic("Parent type not allowed in handleFlatValues.") } - c.Content = content return c } diff --git a/templates/frontmatter.tmpl b/templates/frontmatter.tmpl index b1e56161..8047955e 100644 --- a/templates/frontmatter.tmpl +++ b/templates/frontmatter.tmpl @@ -28,7 +28,7 @@ {{ if eq $value.HTMLType "textarea" }} {{ else if eq $value.HTMLType "datetime" }} - + {{ else }} {{ end }} diff --git a/utils/utils.go b/utils/utils.go index 9096f651..9fd8c7a5 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -89,6 +89,7 @@ func Dict(values ...interface{}) (map[string]interface{}, error) { } dict[key] = values[i+1] } + return dict, nil }