From 68dc43f916791a3f8da523a31f2b702842b62539 Mon Sep 17 00:00:00 2001 From: Dwayne Charrington Date: Fri, 13 Dec 2024 23:21:21 +1000 Subject: [PATCH] fix(search): update fetch path for production added a function to determine the base path based on the environment. now fetches the search index from the correct location in production. --- themes/aurelia-theme/static/js/search.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/themes/aurelia-theme/static/js/search.js b/themes/aurelia-theme/static/js/search.js index 82818ac..a497f9a 100644 --- a/themes/aurelia-theme/static/js/search.js +++ b/themes/aurelia-theme/static/js/search.js @@ -5,10 +5,17 @@ let searchPanel = null; let selectedResult = -1; let searchResultItems = []; +function getBasePath() { + // Check if we're in production by looking for /website in the path + const isProduction = window.location.pathname.includes('/website'); + return isProduction ? '/website' : ''; +} + async function fetchSearchIndex() { if (searchIndex) return searchIndex; - const response = await fetch('/index.json'); + const basePath = getBasePath(); + const response = await fetch(`${basePath}/index.json`); searchIndex = await response.json(); return searchIndex; }