mirror of https://github.com/kiwix/libkiwix.git
Set label to title snippet if present
With openzim/libzim#545 we now support snippet generation of titles which can be used as the display label on the ui for highlighted titles via the "label" field. The old version used plain title which is still available in the value field.
This commit is contained in:
parent
e9ba151e6f
commit
56434de79e
|
@ -510,6 +510,7 @@ bool Reader::searchSuggestionsSmart(const string& prefix,
|
|||
suggestion.push_back(current.getTitle());
|
||||
suggestion.push_back(current.getPath());
|
||||
suggestion.push_back(kiwix::normalize(current.getTitle()));
|
||||
suggestion.push_back(current.getSnippet());
|
||||
results.push_back(suggestion);
|
||||
}
|
||||
retVal = true;
|
||||
|
|
|
@ -415,6 +415,11 @@ std::unique_ptr<Response> InternalServer::handle_suggest(const RequestContext& r
|
|||
for(auto& suggestion:suggestions) {
|
||||
MustacheData result;
|
||||
result.set("label", suggestion[0]);
|
||||
|
||||
if (!suggestion[3].empty()) {
|
||||
result.set("label", suggestion[3]);
|
||||
}
|
||||
|
||||
result.set("value", suggestion[0]);
|
||||
result.set("kind", "path");
|
||||
result.set("path", suggestion[1]);
|
||||
|
|
Loading…
Reference in New Issue