diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-08-25 22:51:38 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-08-25 23:17:26 +0200 |
commit | 5f667f8796fb051e110449dd8d775e947cc1801e (patch) | |
tree | 1aa808b802c98ee568e9c1b1369532aca1204672 | |
parent | e1becf1dfe31bec65eca585ac66a2d10f1651e42 (diff) | |
download | hugo-5f667f8796fb051e110449dd8d775e947cc1801e.tar.gz hugo-5f667f8796fb051e110449dd8d775e947cc1801e.zip |
Fix missing method NameNormalized panic
Closes #12795
-rw-r--r-- | hugolib/content_map_page.go | 2 | ||||
-rw-r--r-- | resources/resource/resourcetypes.go | 8 |
2 files changed, 9 insertions, 1 deletions
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() +} |