diff --git a/scripts/build-algolia.js b/scripts/build-algolia.js index c2104929f2f..c49fe704b80 100755 --- a/scripts/build-algolia.js +++ b/scripts/build-algolia.js @@ -22,7 +22,7 @@ nodes.forEach(node => { title: '', content: '', postref: node.objectID, - objectID: md5(node.permalink), + objectID: null, permalink: node.permalink }; @@ -60,14 +60,17 @@ nodes.forEach(node => { paragraphOut.content = content.textContent; } - // limit the content to 10k so we dont blow up just incase someone decides to make a 40k blog post in one paragraph ¯\_(ツ)_/¯ - paragraphOut.content = paragraphOut.content.substr(0, 8000); + if (paragraphOut.content) { + // limit the content to 10k so we dont blow up just incase someone decides to make a 40k blog post in one paragraph ¯\_(ツ)_/¯ + paragraphOut.content = paragraphOut.content.substr(0, 18000); - // objectID is not quite unique yet so hash the entire object - paragraphOut.objectID = md5(JSON.stringify(paragraphOut)); + // objectID is not quite unique yet so hash the entire object + paragraphOut.objectID = md5(JSON.stringify(paragraphOut)); - nue.push(paragraphOut); + nue.push(paragraphOut); + } + // remove potentially large content (see size limits) and replace with teh summary so that we don't get results with zero highlightable results node.content = node.summary; diff --git a/src/js/app.js b/src/js/app.js index 88c7c994ad4..3d84b04eec6 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -9,6 +9,12 @@ const bootstrapDocsSearch = function() { apiKey: 'b7f43c16886fec97b87981e9e62ef1a5', indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs', routing: true, + searchFunction: function(helper) { + if (helper.state.query === "") { + return; + } + helper.search(); + } }); search.addWidget(