Set the book title only if we have a library.

This commit is contained in:
Matthieu Gautier 2022-02-25 15:15:04 +01:00
parent 921671eb4d
commit d9124ed40b
1 changed files with 4 additions and 2 deletions

View File

@ -98,9 +98,11 @@ std::string SearchRenderer::getHtml()
std::string zim_id(it.getZimId());
result.set("resultContentId", mp_nameMapper->getNameForId(zim_id));
std::shared_ptr<zim::Archive> archive;
try {
if (!mp_library) {
result.set("bookTitle", kainjow::mustache::data(false));
} else {
result.set("bookTitle", mp_library->getBookById(zim_id).getTitle());
} catch (const std::out_of_range& e) {}
}
if (it.getWordCount() >= 0) {
result.set("wordCount", kiwix::beautifyInteger(it.getWordCount()));