--- layout: null --- const algoliaClient = algoliasearch( '{{ site.algolia.application_id }}', '{{ site.algolia.search_only_api_key }}' ); const searchClient = { search(requests) { if (requests.every(({ params }) => !params.query)) { return Promise.resolve({ results: requests.map(() => ({ hits: [], nbHits: 0, nbPages: 0, })), }); } return algoliaClient.search(requests); }, }; const search = instantsearch({ indexName: '{{ site.algolia.index_name }}', searchClient, }); function imgurl(p1) { if (p1 === undefined){ return " " } else if (p1.indexOf("./") === 0) { return p1.replace("./", "{{ '/' | absolute_url }}"); } else if (p1.indexOf("/") === 0) { return p1.replace("/", "{{ '/' | absolute_url }}"); } else { return p1 } } function parsecontent(hit) { if (hit.html === undefined){ return " " } else { return hit._highlightResult.html.value } } function parsetitle(hit) { if (hit.title === undefined){ return "---------" } else { return hit._highlightResult.title.value } } function parseimg(img1, img2){ if (img1 === undefined){ return img2; } else { return img1; } } const hitTemplate = function(hit) { const url = hit.url; const title = parsetitle(hit); const content = parsecontent(hit); const img = parseimg(hit.og_image, hit.header_img); const imglink = imgurl(img); if (img === undefined){ return `

${content}


`; } else { return `

${content}


`; } } search.addWidgets([ instantsearch.widgets.searchBox({ container: '#searchbox', placeholder: '{{ site.search.label | default: "Search" }}...', showReset: false, showSubmit: false, showLoadingIndicator: false, cssClasses: { root: ['input-group'], form: ['input-group'], input: ['form-control', 'rounded'], }, }), {% if site.search.algolia_logo %} instantsearch.widgets.poweredBy({ container: '#powered-by', }), {% endif %} {% raw %} instantsearch.widgets.hits({ container: '#hits', escapeHTML: false, templates: { empty: ` {{#query}}
No results found
{{/query}} `, item: hitTemplate }, }), {% endraw %} ]); search.start();