summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-20 14:12:20 +0200
committerDanilo M. <danix@danix.xyz>2026-04-20 14:12:20 +0200
commit5ff47a6d30bc8e53a17d8e81bfcc1149400aee91 (patch)
treefe166db2d5f9a3e90c9284baea70645f5a868d26
parent2be9dd40a099542c73b2f0fa5d683a44883be9b9 (diff)
downloaddanixxyz-5ff47a6d30bc8e53a17d8e81bfcc1149400aee91.tar.gz
danixxyz-5ff47a6d30bc8e53a17d8e81bfcc1149400aee91.zip
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 <noreply@anthropic.com>
-rw-r--r--themes/danix-xyz-hacker/assets/js/search.js8
1 files changed, 6 insertions, 2 deletions
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;