From 3cbb006eb831a5c22c98d11b6f93be8fa7d86a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 25 Aug 2024 22:51:38 +0200 Subject: [PATCH] Fix missing method NameNormalized panic Closes #12795 --- hugolib/content_map_page.go | 2 +- resources/resource/resourcetypes.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index e3b29f186..c3f06a592 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -560,7 +560,7 @@ func (m *pageMap) getOrCreateResourcesForPage(ps *pageState) resource.Resources for _, r := range res2 { var found bool for _, r2 := range res { - if r2.(resource.NameNormalizedProvider).NameNormalized() == r.(resource.NameNormalizedProvider).NameNormalized() { + if resource.NameNormalizedOrName(r2) == resource.NameNormalizedOrName(r) { found = true break } diff --git a/resources/resource/resourcetypes.go b/resources/resource/resourcetypes.go index 8d982b00a..0fb87f371 100644 --- a/resources/resource/resourcetypes.go +++ b/resources/resource/resourcetypes.go @@ -298,3 +298,11 @@ func (r resourceTypesHolder) ResourceType() string { func NewResourceTypesProvider(mediaType media.Type, resourceType string) ResourceTypesProvider { return resourceTypesHolder{mediaType: mediaType, resourceType: resourceType} } + +// NameNormalizedOrName returns the normalized name if available, otherwise the name. +func NameNormalizedOrName(r Resource) string { + if nn, ok := r.(NameNormalizedProvider); ok { + return nn.NameNormalized() + } + return r.Name() +}