From: Danilo M. Date: Mon, 20 Apr 2026 12:12:20 +0000 (+0200) Subject: fix: make search index language-aware X-Git-Tag: release_22042026-1342~62 X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=5ff47a6d30bc8e53a17d8e81bfcc1149400aee91;p=danix.xyz-2.git fix: make search index language-aware loadSearchIndex() now detects current language from URL pathname. If on /it/* path, loads /it/search-index.json; otherwise loads /search-index.json. Ensures search results link to correct language version of articles. Co-Authored-By: Claude Haiku 4.5 --- diff --git a/themes/danix-xyz-hacker/assets/js/search.js b/themes/danix-xyz-hacker/assets/js/search.js index 94c6323..8fb6262 100644 --- a/themes/danix-xyz-hacker/assets/js/search.js +++ b/themes/danix-xyz-hacker/assets/js/search.js @@ -1,10 +1,14 @@ -// 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;