Add support for highlighting results
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user