From 77cbbf600b9cb87942d4f0f9f09572e63d66a3de Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 20 Apr 2026 20:42:58 -0400 Subject: [PATCH] refactor(docs): replace deprecated strings.Title with cases.Title strings.Title has been deprecated since Go 1.18 because it does not handle Unicode properly. Replace it with cases.Title from golang.org/x/text which correctly handles language-specific title casing. Applied to breadcrumb generation and document title formatting. --- internal/docs/handler.go | 8 +++++--- internal/docs/navigation.go | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/docs/handler.go b/internal/docs/handler.go index 1c80397..1a3b416 100644 --- a/internal/docs/handler.go +++ b/internal/docs/handler.go @@ -7,13 +7,15 @@ import ( "os" "strings" + "bookhoard/templates" + "github.com/yuin/goldmark" highlighting "github.com/yuin/goldmark-highlighting" "github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/parser" "github.com/yuin/goldmark/renderer/html" - - "bookhoard/templates" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) type DocsHandler struct { @@ -169,7 +171,7 @@ func (h *DocsHandler) generateBreadcrumb(docPath string) []templates.BreadcrumbI // Don't add the last part (current page) if i < len(parts)-1 { breadcrumb = append(breadcrumb, templates.BreadcrumbItem{ - Title: strings.Title(strings.ReplaceAll(part, "-", " ")), + Title: cases.Title(language.English).String(strings.ReplaceAll(part, "-", " ")), URL: "/docs" + path, }) } diff --git a/internal/docs/navigation.go b/internal/docs/navigation.go index c960c63..3f682b1 100644 --- a/internal/docs/navigation.go +++ b/internal/docs/navigation.go @@ -5,6 +5,9 @@ import ( "strings" "bookhoard/templates" + + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // BuildNavigation creates the navigation structure from the docs filesystem @@ -100,7 +103,7 @@ func (h *DocsHandler) getDocTitle(docPath string) string { filename := parts[len(parts)-1] // Convert to title case - title = strings.Title(strings.ReplaceAll(filename, "-", " ")) + title = cases.Title(language.English).String(strings.ReplaceAll(filename, "-", " ")) // Handle special cases switch filename {