-// Lazy-load search index from JSON file
+// Lazy-load search index from JSON file (language-aware)
async function loadSearchIndex() {
if (window.searchIndex) {
return window.searchIndex;
}
try {
- const response = await fetch('/search-index.json');
+ // Detect current language from URL
+ const isItalian = window.location.pathname.startsWith('/it/');
+ const indexPath = isItalian ? '/it/search-index.json' : '/search-index.json';
+
+ const response = await fetch(indexPath);
if (!response.ok) throw new Error('Failed to load search index');
window.searchIndex = await response.json();
return window.searchIndex;