This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-website.git
commit a52620acc9b702d220e4cc57d899a7bba4985b76 Author: nayananga@ubuntu <[email protected]> AuthorDate: Sun Mar 1 22:54:04 2020 +0530 update: show no result text on empty search results --- antora-ui-camel/src/js/06-search.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/antora-ui-camel/src/js/06-search.js b/antora-ui-camel/src/js/06-search.js index 4560845..2153ef5 100644 --- a/antora-ui-camel/src/js/06-search.js +++ b/antora-ui-camel/src/js/06-search.js @@ -49,21 +49,27 @@ window.addEventListener('load', () => { return data }) .then((data) => { - return ` - <dl> - ${Object.keys(data).map((section) => ` - <dt>${section}</dt> - ${data[section].map((hit) => ` - <a href="${hit.url}"> - <dd> - <header>${hit.breadcrumbs}</header> - <summary>${hit.snippet}</summary> - </dd> - </a> - `).join('')} - `).join('')} - </dl> - ` + if (Object.entries(data).length === 0 && data.constructor === Object) { + return ` + <header>Nothing Found</header> + ` + } else { + return ` + <dl> + ${Object.keys(data).map((section) => ` + <dt>${section}</dt> + ${data[section].map((hit) => ` + <a href="${hit.url}"> + <dd> + <header>${hit.breadcrumbs}</header> + <summary>${hit.snippet}</summary> + </dd> + </a> + `).join('')} + `).join('')} + </dl> + ` + } }) .then((markup) => { results.innerHTML = markup
