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:
Maneesh P M 2021-05-08 21:26:17 +05:30 committed by Matthieu Gautier
parent e9ba151e6f
commit 56434de79e
2 changed files with 6 additions and 0 deletions

View File

@ -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;

View File

@ -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]);