diff --git a/src/config/_default/config.toml b/src/config/_default/config.toml index 2696a536..09f10076 100644 --- a/src/config/_default/config.toml +++ b/src/config/_default/config.toml @@ -22,6 +22,7 @@ defaultContentLanguageInSubdir = true weight = 1 [languages.en.outputs] home = ["HTML", "LLMS"] + section = ["JSON", "HTML", "RSS"] [languages.es] languageCode = "es" contentDir = 'content/es' diff --git a/src/themes/ivpn-v3/assets/js/search.js b/src/themes/ivpn-v3/assets/js/search.js index 46449ad7..41480648 100644 --- a/src/themes/ivpn-v3/assets/js/search.js +++ b/src/themes/ivpn-v3/assets/js/search.js @@ -24,11 +24,26 @@ const app = createApp({ } }, fetchAndSearch(query) { - fetch('/en/pages/index.json') - .then(response => response.json()) + // Derive locale from the current URL path (/en/..., /es/..., etc.) + // so the correct per-locale index is fetched. Fall back to 'en'. + const knownLocales = ['en', 'es']; + const firstSegment = window.location.pathname.split('/').filter(Boolean)[0] || ''; + const locale = knownLocales.includes(firstSegment) ? firstSegment : 'en'; + fetch(`/${locale}/pages/index.json`) + .then(response => { + if (!response.ok) { + // Try the English index as a fallback + return fetch('/en/pages/index.json').then(r => r.json()); + } + return response.json(); + }) .then(data => { this.collection = data this.search(data, query) + }) + .catch(() => { + this.renderTitle([], query) + this.renderList([]) }); }, search(data, query) {