From 9c047844c0fedc6d1cce00f75e087bc1d56db464 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Wed, 29 Dec 2021 00:03:50 +0530 Subject: [PATCH] Add fallback if metadata (title, description, language, tags) This provides a workaround the crash happening because of missing metadata. Language div is set to be hidden if no language data is found --- static/skin/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/skin/index.js b/static/skin/index.js index 413aad469..223982f84 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -67,7 +67,8 @@ } function getInnerHtml(node, query) { - return node.querySelector(query).innerHTML; + const queryNode = node.querySelector(query); + return queryNode != null ? queryNode.innerHTML : ""; } function generateBookHtml(book, sort = false) { @@ -103,6 +104,7 @@ if (sort) { divTag.setAttribute('data-idx', bookOrderMap.get(id)); } + const languageAttr = language != '' ? '' : 'style="background-color: transparent"'; divTag.innerHTML = `
@@ -111,7 +113,7 @@ ${downloadLink ? `
Download ${humanFriendlyZimSize ? ` - ${humanFriendlyZimSize}
`: ''}` : ''}
${description}
-
${language.substr(0, 2).toUpperCase()}
+
${language.substr(0, 2).toUpperCase()}
${tagHtml}
`; return divTag;