Skip to content

Commit 5793979

Browse files
committed
dont load initially
1 parent af4cda6 commit 5793979

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

layouts/index.html

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ <h2 class="pt-5 color-blue">Search</h2>
103103
indexName: 'website_pages',
104104
searchClient,
105105
future: { preserveSharedStateOnUnmount: true },
106+
searchFunction: function(helper) {
107+
if (helper.state.query === '') {
108+
return;
109+
}
110+
helper.search();
111+
}
106112
});
107113

108114
let lastRenderArgs;
@@ -116,12 +122,19 @@ <h2 class="pt-5 color-blue">Search</h2>
116122

117123
if (isFirstRender) {
118124
const sentinel = document.createElement('div');
119-
container.appendChild(document.createElement('ul'));
125+
const containerDiv = document.createElement('div');
126+
containerDiv.className = 'ais-Hits';
127+
const containerOl = document.createElement('ol');
128+
containerOl.className = 'ais-Hits-list';
129+
containerDiv.appendChild(containerOl);
130+
container.appendChild(containerDiv);
120131
container.appendChild(sentinel);
121132

122133
const observer = new IntersectionObserver(entries => {
123134
entries.forEach(entry => {
124-
if (entry.isIntersecting && !lastRenderArgs.isLastPage) {
135+
if (entry.isIntersecting
136+
&& !lastRenderArgs.isLastPage
137+
&& $(document.activeElement)?.attr("class") === "ais-SearchBox-input" ) {
125138
showMore();
126139
}
127140
});
@@ -132,23 +145,25 @@ <h2 class="pt-5 color-blue">Search</h2>
132145
return;
133146
}
134147

135-
container.querySelector('ul').innerHTML = items
148+
container.querySelector('ol').innerHTML = items
136149
.map(
137150
item => {
138151
return `
139-
<a href=${item.url} class="container">
140-
<div class="row search-result-row bg-white">
141-
<div class="col-12 col-lg-2">
142-
<div class="my-3">
143-
<img class="image-fluid search-result-image d-flex" src=${item.image} alt=${item.title} />
152+
<li class="ais-Hits-item">
153+
<a href=${item.url} class="container">
154+
<div class="row search-result-row">
155+
<div class="col-12 col-lg-2">
156+
<div class="my-3">
157+
<img class="image-fluid search-result-image d-flex" src=${item.image} alt=${item.title} />
158+
</div>
159+
</div>
160+
<div class="col-12 col-lg-10">
161+
<h3 class="color-blue search-result-title">${item.title}</h3>
162+
<p class="color-gray search-result-subtitle">${item.subtitle}</p>
144163
</div>
145164
</div>
146-
<div class="col-12 col-lg-10">
147-
<h3 class="color-blue search-result-title">${item.title}</h3>
148-
<p class="color-gray search-result-subtitle">${item.subtitle}</p>
149-
</div>
150-
</div>
151-
</a>
165+
</a>
166+
</li>
152167
`;
153168
})
154169
.join('');
@@ -159,7 +174,7 @@ <h3 class="color-blue search-result-title">${item.title}</h3>
159174
container: '#searchbox',
160175
}),
161176
instantsearch.widgets.configure({
162-
hitsPerPage: 8,
177+
hitsPerPage: 3,
163178
filters: "language:{{$.Site.Language.Lang}}"
164179
}),
165180
infiniteHits({

0 commit comments

Comments
 (0)