Skip to content

Commit

Permalink
brute force revert to check pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
cstns committed Oct 10, 2024
1 parent 4b0640c commit cb542c7
Showing 1 changed file with 0 additions and 94 deletions.
94 changes: 0 additions & 94 deletions src/_includes/layouts/common-js.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,99 +22,5 @@
<link rel="preload" href="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-theme-classic" as="style" onload="this.onload=null;this.rel='stylesheet'" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script async type="text/javascript" src="https://cdn.jsdelivr.net/npm/@algolia/algoliasearch-netlify-frontend@1/dist/algoliasearchNetlify.js" onload="initSearchBar()"></script>
<script async type="text/javascript">
const searchScope = document.head.querySelector('[property="article:section"][content]')?.content ?? '';
function initSearchBar() {
const {autocomplete, getAlgoliaResults} = window['@algolia/autocomplete-js'];
const searchClient = algoliasearch('KWE0727TZS', '595ee07f069991380e9c3036cfad8e5e');
const scopeTitles = {
'ama': 'Ask Me Anything',
'blog': 'Blog',
'changelog': 'Changelog',
'customer-stories': 'Customer Stories',
'docs': 'Docs',
'ebooks': 'E-Books',
'handbook': 'Handbook',
'node-red': 'Node-RED',
'webinars': 'Webinars',
}
const placeholder = Object.prototype.hasOwnProperty.call(scopeTitles, searchScope) ? `Search in ${scopeTitles[searchScope]}...` : 'Search...'
const searchQuery = (searchClient, query, scope) => {
return {
sourceId : scope,
getItems : () => getAlgoliaResults({
searchClient,
queries: [
{
indexName : 'netlify_00f8cf60-997f-4c4d-9427-a97924358648_live_all',
params : {
query,
hitsPerPage: 5,
},
attributesToHighlight: '*',
filters: scope.length === 0 ? undefined : `category:${scope}`
},
],
}),
templates: {
header({html}) {
if (!Object.prototype.hasOwnProperty.call(scopeTitles, scope)) {
return null;
}
return html`
<span class="aa-SourceHeaderTitle">In ${scopeTitles[scope]}</span>
<div class="aa-SourceHeaderLine"/>
`;
},
item({item, components, html}) {
return html`
<a href="${item.url}" class="aa-ItemWrapper">
<div class="aa-ItemContent">
<div class="aa-ItemIcon aa-ItemIcon--alignTop">
<img
src="${item.image}"
alt="${item.name}"
width="40"
height="40"
/>
</div>
<div class="aa-ItemContentBody">
<div class="aa-ItemContentTitle">
${components.Highlight({
hit : item,
attribute: ['hierarchy', 'lvl0'],
})}
</div>
<div class="aa-ItemContentSubTitle ${item.type === 'lvl0' ? 'hidden' : ''}">
${components.Highlight({
hit : item,
attribute: ['hierarchy', item.type],
})}
</div>
<div class="aa-ItemContentDescription">
${components.Snippet({
hit : item,
attribute: 'description',
})}
</div>
</div>
</div>
</a>`;
},
},
};
}
autocomplete({
container: '#algolia-search',
placeholder,
getSources({query}) {
return [
searchQuery(searchClient, query, searchScope)
]
}
});
}
</script>

0 comments on commit cb542c7

Please sign in to comment.