Fix some related content issues with content adapters

Fixes #13443
This commit is contained in:
Bjørn Erik Pedersen
2025-02-25 11:28:59 +01:00
parent 227e429267
commit 381c0da85d
8 changed files with 151 additions and 16 deletions

View File

@@ -21,6 +21,7 @@ import (
"time"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/config"
)
type testDoc struct {
@@ -249,6 +250,50 @@ func TestToKeywordsToLower(t *testing.T) {
})
}
func TestDecodeConfig(t *testing.T) {
c := qt.New(t)
configToml := `
[related]
includeNewer = true
threshold = 32
toLower = false
[[related.indices]]
applyFilter = false
cardinalityThreshold = 0
name = 'KeyworDs'
pattern = ''
toLower = false
type = 'basic'
weight = 100
[[related.indices]]
applyFilter = true
cardinalityThreshold = 32
name = 'date'
pattern = ''
toLower = false
type = 'basic'
weight = 10
[[related.indices]]
applyFilter = false
cardinalityThreshold = 0
name = 'tags'
pattern = ''
toLower = false
type = 'fragments'
weight = 80
`
m, err := config.FromConfigString(configToml, "toml")
c.Assert(err, qt.IsNil)
conf, err := DecodeConfig(m.GetParams("related"))
c.Assert(err, qt.IsNil)
c.Assert(conf.IncludeNewer, qt.IsTrue)
first := conf.Indices[0]
c.Assert(first.Name, qt.Equals, "keywords")
}
func TestToKeywordsAnySlice(t *testing.T) {
c := qt.New(t)
var config IndexConfig