handle pluralising minute(s)

Amolith created

Change summary

main.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

Detailed changes

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