Skip to content

Commit e96c608

Browse files
committed
Remove direct search index reference from searcher
Because `{{resource}}` references don't affect the hash[^1], we need to avoid referencing dynamic content from within static content. Otherwise, you get a cached searcher.js referencing a searchindex that no longer exists. [^1]: if we made it affect the hash, we'd have to do full dependency tracking, and we'd no longer be able to support circular refs
1 parent e6315bf commit e96c608

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/front-end/searcher/searcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ window.search = window.search || {};
434434

435435
function showSearch(yes) {
436436
if (yes) {
437-
loadSearchScript(path_to_root + '{{ resource "searchindex.js" }}', 'search-index');
437+
loadSearchScript(window.path_to_searchindex_js, 'search-index');
438438
search_wrap.classList.remove('hidden');
439439
searchicon.setAttribute('aria-expanded', 'true');
440440
} else {

src/front-end/templates/index.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
const path_to_root = "{{ path_to_root }}";
5959
const default_light_theme = "{{ default_theme }}";
6060
const default_dark_theme = "{{ preferred_dark_theme }}";
61+
{{#if search_js}}
62+
window.path_to_searchindex_js = "{{ resource "searchindex.js" }}";
63+
{{/if}}
6164
</script>
6265
<!-- Start loading toc.js asap -->
6366
<script src="{{ resource "toc.js" }}"></script>

0 commit comments

Comments
 (0)