From e6fa74df617ca1938ccc37722598c7bd37bc7c8b Mon Sep 17 00:00:00 2001
From: Kevin Veen-Birkenbach <kevin@veen.world>
Date: Mon, 17 Mar 2025 16:41:50 +0100
Subject: [PATCH] Prevent js exception

---
 sphinx/_static/current-nav.js   | 3 ++-
 sphinx/templates/structure.html | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sphinx/_static/current-nav.js b/sphinx/_static/current-nav.js
index 67d189de..64b73460 100644
--- a/sphinx/_static/current-nav.js
+++ b/sphinx/_static/current-nav.js
@@ -94,4 +94,5 @@
         });
       });
     }
-  });
\ No newline at end of file
+    window.initCurrentNav = initCurrentNav;
+  });
diff --git a/sphinx/templates/structure.html b/sphinx/templates/structure.html
index 778204d8..93e6ca42 100644
--- a/sphinx/templates/structure.html
+++ b/sphinx/templates/structure.html
@@ -42,7 +42,7 @@
 {% if local_md_headings or local_subfolders %}
 <div class="local-md-headings">
   {% if local_md_headings %}
-  <div class="current-index" x-data x-init="initCurrentNav()">
+  <div class="current-index" x-data x-init="typeof initCurrentNav === 'function' && initCurrentNav()">
     <p class="caption" role="heading">
       <span class="caption-text">Current Index</span>
     </p>