Add support for highlighting results

This commit is contained in:
James Mills
2021-02-07 21:15:34 +10:00
parent ce4b180576
commit d96293007b
5 changed files with 189 additions and 185 deletions

View File

@@ -212,13 +212,13 @@ func (s *Server) SearchHandler() httprouter.Handle {
var results []Result
for _, searchResult := range searchResults.Hits {
for _, hit := range searchResults.Hits {
result := Result{
ID: searchResult.ID,
Title: searchResult.Fields["Title"].(string),
Summary: searchResult.Fields["Summary"].(string),
URL: searchResult.Fields["URL"].(string),
Length: int(searchResult.Fields["Length"].(float64)),
ID: hit.ID,
Title: hit.Fields["Title"].(string),
Summary: template.HTML(strings.Join(hit.Fragments["Summary"], "")),
URL: hit.Fields["URL"].(string),
Length: int(hit.Fields["Length"].(float64)),
}
results = append(results, result)
}

View File

@@ -1,10 +1,12 @@
package internal
import "html/template"
type Result struct {
ID string
URL string
Title string
Summary string
Summary template.HTML
Length int
}

File diff suppressed because one or more lines are too long