Skip to content

Commit 6ae96e7

Browse files
leroyCalinou
andauthored
Implemented Algolia search (#4884)
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
1 parent 82ea79d commit 6ae96e7

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

_static/css/algolia.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.wy-nav-side { overflow: visible; }
2+
.wy-side-scroll { overflow: inherit; }
3+
4+
.algolia-autocomplete {
5+
display: block !important;
6+
}

_static/js/algolia.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
(function() {
3+
4+
var doc_version = document.querySelector('meta[name="doc_version"]').getAttribute('content');
5+
6+
// Initialize the Algolia search widget
7+
docsearch({
8+
apiKey: 'c39cb614363a2a156811478bc2d0573b',
9+
indexName: 'godotengine',
10+
inputSelector: '#rtd-search-form input[type=text]',
11+
algoliaOptions: {
12+
facetFilters: ["version:" + (doc_version || 'stable')]
13+
},
14+
});
15+
16+
window.addEventListener('keydown', function(event) {
17+
if (event.key === '/') {
18+
document.querySelector('#rtd-search-form input[type=text]').focus();
19+
event.preventDefault();
20+
}
21+
})
22+
})();

_templates/layout.html

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{% extends "!layout.html" -%}
2+
3+
{% block extrahead -%}
4+
<meta name="doc_version" content="{{ version }}">
5+
{% endblock -%}
6+
27
{% block linktags -%}
38
<meta name="theme-color" content="#3d8fcc">
49
{% if godot_inject_language_links -%}

conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
if not os.getenv("SPHINX_NO_GDSCRIPT"):
6262
extensions.append("gdscript")
6363

64-
if not os.getenv("SPHINX_NO_SEARCH"):
65-
extensions.append("sphinx_search.extension")
66-
6764
if not os.getenv("SPHINX_NO_DESCRIPTIONS"):
6865
extensions.append("godot_descriptions")
6966

@@ -189,11 +186,15 @@
189186
# These paths are either relative to html_static_path
190187
# or fully qualified paths (e.g. https://...)
191188
html_css_files = [
189+
'css/algolia.css',
190+
'https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css',
192191
"css/custom.css",
193192
]
194193

195194
html_js_files = [
196195
"js/custom.js",
196+
('https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js', {'defer': 'defer'}),
197+
('js/algolia.js', {'defer': 'defer'})
197198
]
198199

199200
# Output file base name for HTML help builder

requirements.txt

-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ sphinx-notfound-page==0.7.1
1515

1616
# Adds Open Graph tags in the HTML `<head>` tag
1717
sphinxext-opengraph==0.4.2
18-
19-
# Full-page search UI for RTD: https://readthedocs-sphinx-search.readthedocs.io
20-
readthedocs-sphinx-search==0.1.0

0 commit comments

Comments
 (0)