hugolib: Implement "related content"

This closes #98, even if this commit does not do full content text search.

We may revisit that problem in the future, but that deserves its own issue.

Fixes #98
This commit is contained in:
Bjørn Erik Pedersen
2017-08-19 13:16:00 +02:00
parent 16c9127663
commit 3b4f17bbc9
14 changed files with 1151 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cast"
@@ -641,3 +642,8 @@ func (ns *Namespace) Uniq(l interface{}) (interface{}, error) {
}
return ret.Interface(), nil
}
// KeyVals creates a key and values wrapper.
func (ns *Namespace) KeyVals(key interface{}, vals ...interface{}) (types.KeyValues, error) {
return types.KeyValues{Key: key, Values: vals}, nil
}

View File

@@ -63,6 +63,13 @@ func init() {
[][2]string{},
)
ns.AddMethodMapping(ctx.KeyVals,
[]string{"keyVals"},
[][2]string{
{`{{ keyVals "key" "a" "b" }}`, `key: [a b]`},
},
)
ns.AddMethodMapping(ctx.In,
[]string{"in"},
[][2]string{