You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2020/03/04 13:01:54 UTC
[camel-website] 05/13: update: show no result text on empty search
results
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 <na...@gmail.com>
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