Skip to content

Commit

Permalink
fix: correctly show article date on post page
Browse files Browse the repository at this point in the history
  • Loading branch information
pluja committed Mar 15, 2024
1 parent 7748dc9 commit af50ac2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions blogo/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func createTemplate(files []string) *template.Template {
readTime := math.Ceil(float64(wordCount) / float64(readSpeed))
return int(readTime)
},
"dateString": func(t time.Time) string {
return t.Format("2006-01-02")
},
}

tmpl := template.New("").Funcs(funcMap)
Expand Down
4 changes: 2 additions & 2 deletions templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ <h1 class="pt-4 mb-2 text-4xl font-bold text-gray-900 text-opacity-90 capitalize
{{end}}
{{if ne .Article.Author ""}}
<div class="mb-0 text-xs text-black drop-shadow-sm dark:text-slate-100">~{{readTime .Article.Md}} min read</div>
<div class="mb-0 text-sm text-black drop-shadow-sm dark:text-slate-100">by {{.Article.Author}}, {{humanizeTime .Article.Date}}</div>
<div class="mb-0 text-sm text-black drop-shadow-sm dark:text-slate-100">by {{.Article.Author}}, {{dateString .Article.Date}}</div>
{{else}}
<div class="mt-2 mb-0 text-sm font-bold text-black dark:text-slate-100">{{humanizeTime .Article.Date}}</div>
<div class="mt-2 mb-0 text-sm font-bold text-black dark:text-slate-100">{{dateString .Article.Date}}</div>
{{end}}
{{if and (ne .Article.NostrUrl "") (ne .Article.NostrUrl "0") (ne .Article.NostrUrl "false")}}
<div class="pb-2 text-center">
Expand Down

0 comments on commit af50ac2

Please sign in to comment.