diff --git a/source/js/third-party/search/algolia-search.js b/source/js/third-party/search/algolia-search.js index d6adab4..d13a138 100644 --- a/source/js/third-party/search/algolia-search.js +++ b/source/js/third-party/search/algolia-search.js @@ -1,4 +1,4 @@ -/* global instantsearch, algoliasearch, CONFIG */ +/* global instantsearch, algoliasearch, CONFIG, pjax */ document.addEventListener('DOMContentLoaded', () => { const { indexName, appID, apiKey, hits } = CONFIG.algolia; @@ -13,9 +13,11 @@ document.addEventListener('DOMContentLoaded', () => { } }); - window.pjax && search.on('render', () => { - window.pjax.refresh(document.querySelector('.algolia-hits')); - }); + if (typeof pjax === 'object') { + search.on('render', () => { + pjax.refresh(document.querySelector('.algolia-hits')); + }); + } // Registering Widgets search.addWidgets([ diff --git a/source/js/third-party/search/local-search.js b/source/js/third-party/search/local-search.js index 3159920..62c9202 100644 --- a/source/js/third-party/search/local-search.js +++ b/source/js/third-party/search/local-search.js @@ -1,4 +1,4 @@ -/* global CONFIG */ +/* global CONFIG, pjax */ document.addEventListener('DOMContentLoaded', () => { if (!CONFIG.path) { @@ -192,7 +192,7 @@ document.addEventListener('DOMContentLoaded', () => { container.innerHTML = `