From 922cf7e7ca2ffefd52d998b2eb922d851a4c7301 Mon Sep 17 00:00:00 2001 From: Graham Barber Date: Wed, 14 Aug 2024 20:10:47 -0700 Subject: [PATCH] sort posts on home screen correctly --- handlers/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/routes.go b/handlers/routes.go index da662ec..9d7352c 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -13,7 +13,7 @@ import ( func ServeHomePage(w http.ResponseWriter, r *http.Request) { posts := make([]*models.Post, 0) - result := storage.GORM().Limit(10).Find(&posts) + result := storage.GORM().Limit(10).Order("created_at DESC").Find(&posts) if result.Error != nil { panic(result.Error) } -- knotmirror 0.0.1