I am working on an open source repo that make hugo and bleve search work well together.
But i upgraded hugo and the function signature has changed and i cant seem to get a Context off the Page.
Its very simple code luckily. I am digging into the hugo code base to see if its possible, and would appreciate some advice.
go build .
# github.com/tischda/hugo-search
./model.go:40:25: context.Context (type) is not an expression
./model.go:41:25: not enough arguments in call to p.WordCount
have ()
want (context.Context)
./model.go:42:25: not enough arguments in call to p.ReadingTime
have ()
want (context.Context)
package main
import (
"strings"
"time"
"github.com/gohugoio/hugo/resources/page"
)
// PageEntry maps the hugo internal page structure to a JSON structure
// that blevesearch can understand.
type PageEntry struct {
Title string `json:"title"`
Type string `json:"type"`
Section string `json:"section"`
Content string `json:"content"`
WordCount float64 `json:"word_count"`
ReadingTime float64 `json:"reading_time"`
Keywords []string `json:"keywords"`
Date time.Time `json:"date"`
LastModified time.Time `json:"last_modified"`
Author string `json:"author"`
}
func newIndexEntry(p page.Page) *PageEntry {
var author string
switch str := p.Params()["author"].(type) {
case string:
author = str
case []string:
author = strings.Join(str, ", ")
}
return &PageEntry{
Title: p.Title(),
Type: p.Type(),
Section: p.Section(),
Content: p.Plain(),
WordCount: float64(p.WordCount()),
ReadingTime: float64(p.ReadingTime()),
Keywords: p.Keywords(),
Date: p.Date(),
LastModified: p.Lastmod(),
Author: author,
}
}