Skip to content

Commit

Permalink
feat: Update search
Browse files Browse the repository at this point in the history
  • Loading branch information
oodamien committed Jan 26, 2024
1 parent 9188b8e commit 1c315f1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/js/vendor/search.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

;(function () {
const isMac = () => navigator.platform.indexOf('Mac') > -1

let loaded = false
const config = document.getElementById('search-script').dataset
const client = algoliasearch(config.appId, config.apiKey)
let selected = null
Expand All @@ -14,6 +14,10 @@

let lastRenderArgs

const decodeHtmlEntities = (str) => {
return str.replaceAll('<', '<').replaceAll('>', '>')
}

const infiniteHits = instantsearch.connectors.connectInfiniteHits((renderArgs, isFirstRender) => {
const { hits, showMore, widgetParams } = renderArgs
const { container } = widgetParams
Expand Down Expand Up @@ -80,14 +84,13 @@
.filter((item) => !!item)
.join(' - ')

console.log(label)
return `<li>
<a href="${hit.url}" class="ais-Hits-item">
<div class="hit-name">
${label}
${decodeHtmlEntities(label)}
</div>
${breadcrumbs}
${content}
${decodeHtmlEntities(breadcrumbs)}
${decodeHtmlEntities(content)}
</a>
</li>`
})
Expand Down Expand Up @@ -219,9 +222,11 @@
}),
])

search.start()

const open = () => {
if (!loaded) {
search.start()
loaded = true
}
selectHit(null)
MicroModal.show('modal-1', {
disableScroll: true,
Expand Down

0 comments on commit 1c315f1

Please sign in to comment.