mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix date formats in frotmatter. close #28
This commit is contained in:
parent
f0175875b3
commit
427989d639
@ -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
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
{{ if eq $value.HTMLType "textarea" }}
|
||||
<textarea class="scroll" name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" data-parent-type="{{ $value.Parent.Type }}">{{ $value.Content }}</textarea>
|
||||
{{ else if eq $value.HTMLType "datetime" }}
|
||||
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content }}" type="text" data-parent-type="{{ $value.Parent.Type }}"></input>
|
||||
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content.Format "2006-01-02T15:04:05" }}" type="datetime-local" data-parent-type="{{ $value.Parent.Type }}"></input>
|
||||
{{ else }}
|
||||
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content }}" type="{{ $value.HTMLType }}" data-parent-type="{{ $value.Parent.Type }}"></input>
|
||||
{{ end }}
|
||||
|
@ -89,6 +89,7 @@ func Dict(values ...interface{}) (map[string]interface{}, error) {
|
||||
}
|
||||
dict[key] = values[i+1]
|
||||
}
|
||||
|
||||
return dict, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user