diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-04-20 17:42:57 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-04-23 22:22:50 +0200 |
commit | 05b45c35c8067b7c4a6c99fec64f124739d2e7fd (patch) | |
tree | 31a5bb0dd08c0e73835a2482c65d6de97ffb7634 /tpl | |
parent | 625be77e083bf992ce81295fb875a664c68bcef3 (diff) | |
download | hugo-05b45c35c8067b7c4a6c99fec64f124739d2e7fd.tar.gz hugo-05b45c35c8067b7c4a6c99fec64f124739d2e7fd.zip |
tpl/lang: Handle nil values in lang.Merge
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/lang/lang.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go index 33c4c093b..ee349bd1d 100644 --- a/tpl/lang/lang.go +++ b/tpl/lang/lang.go @@ -24,6 +24,7 @@ import ( translators "github.com/gohugoio/localescompressed" "github.com/pkg/errors" + "github.com/gohugoio/hugo/common/hreflect" "github.com/gohugoio/hugo/deps" "github.com/spf13/cast" ) @@ -250,6 +251,12 @@ type pagesLanguageMerger interface { // Merge creates a union of pages from two languages. func (ns *Namespace) Merge(p2, p1 any) (any, error) { + if !hreflect.IsTruthful(p1) { + return p2, nil + } + if !hreflect.IsTruthful(p2) { + return p1, nil + } merger, ok := p1.(pagesLanguageMerger) if !ok { return nil, fmt.Errorf("language merge not supported for %T", p1) |