Repository: gohugoio/hugo (language: go)

Issue:
panic related to translationKey and page resources
> panic: interface conversion: *hugolib.pageState is not resource.NameNormalizedProvider: missing method NameNormalized

The panic occurs with [v0.123.4](https://github.com/gohugoio/hugo/releases/tag/v0.123.4) and later, and seems to be triggered (at least in part) by the translationKey field in front matter.

Reproducible example:

```text
git clone --single-branch -b hugo-forum-topic-51282 https://github.com/jmooring/hugo-testing hugo-forum-topic-51282
cd hugo-forum-topic-51282
hugo
```

Reference: <https://discourse.gohugo.io/t/51282>


Discussion / hints:

Fix patch:
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index e3b29f186b3..c3f06a592ba 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 8d982b00a7e..0fb87f37137 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()
+}


Test patch: