Implemented Algolia search (#4884)

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
Leroy Bakker
2021-06-13 20:21:11 +02:00
committed by GitHub
parent 82ea79d825
commit 6ae96e7b50
5 changed files with 37 additions and 6 deletions

22
_static/js/algolia.js Normal file
View File

@@ -0,0 +1,22 @@
(function() {
var doc_version = document.querySelector('meta[name="doc_version"]').getAttribute('content');
// Initialize the Algolia search widget
docsearch({
apiKey: 'c39cb614363a2a156811478bc2d0573b',
indexName: 'godotengine',
inputSelector: '#rtd-search-form input[type=text]',
algoliaOptions: {
facetFilters: ["version:" + (doc_version || 'stable')]
},
});
window.addEventListener('keydown', function(event) {
if (event.key === '/') {
document.querySelector('#rtd-search-form input[type=text]').focus();
event.preventDefault();
}
})
})();