diff --git a/main.go b/main.go index f5d5a5f519a12a8be583979a22f7749a9eb5b468..cdff75dcb6fe0a3e979131c023a9135a174237c3 100644 --- a/main.go +++ b/main.go @@ -107,7 +107,7 @@ func main() { return rTime.Layout(gtx) }), layout.Rigid(func(gtx layout.Context) layout.Dimensions { - rTime := material.Label(th, unit.Sp(float32(*flagMetaSize)), fmt.Sprint(postReadTime, " minutes")) + rTime := material.Label(th, unit.Sp(float32(*flagMetaSize)), postReadTime) rTime.Font = text.Font{Typeface: "Primary font", Variant: "", Style: text.Regular, Weight: text.Normal} rTime.Alignment = text.End return rTime.Layout(gtx) @@ -359,12 +359,12 @@ func getPostInfo(input string) (string, string, string) { } // Get the read time of the post -func getReadTime(content string) int { +func getReadTime(content string) string { wordCount := len(strings.Fields(content)) - if wordCount/200 == 0 { - return 1 + if wordCount/200 == 0 || wordCount/200 == 1 { + return "1 minute" } - return wordCount / 200 + return fmt.Sprintf("%d minutes", wordCount/200) } // Get the site's title