From 3346c91f966697dc8abc41b6bdae0765993173ed Mon Sep 17 00:00:00 2001 From: yusing Date: Thu, 1 Jan 2026 12:31:36 +0800 Subject: [PATCH] fix(homepage): improve alphabetical sorting by normalizing item names (#181) - Updated the sorting function to use Title case for item names to ensure consistent alphabetical ordering. --- internal/homepage/homepage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/homepage/homepage.go b/internal/homepage/homepage.go index e4a0c5d2..739496c6 100644 --- a/internal/homepage/homepage.go +++ b/internal/homepage/homepage.go @@ -7,6 +7,7 @@ import ( "github.com/yusing/ds/ordered" "github.com/yusing/godoxy/internal/homepage/widgets" "github.com/yusing/godoxy/internal/serialization" + strutils "github.com/yusing/goutils/strings" ) type ( @@ -146,13 +147,13 @@ func (c *Category) sortByClicks() { return 1 } // fallback to alphabetical - return strings.Compare(a.Name, b.Name) + return strings.Compare(strutils.Title(a.Name), strutils.Title(b.Name)) }) } func (c *Category) sortByAlphabetical() { slices.SortStableFunc(c.Items, func(a, b *Item) int { - return strings.Compare(a.Name, b.Name) + return strings.Compare(strutils.Title(a.Name), strutils.Title(b.Name)) }) }