Skip to content

Commit

Permalink
fix(search): update fetch path for production
Browse files Browse the repository at this point in the history
added a function to determine the base path based on the environment. now fetches the search index from the correct location in production.
  • Loading branch information
Vheissu committed Dec 13, 2024
1 parent c50c67b commit 68dc43f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion themes/aurelia-theme/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 68dc43f

Please sign in to comment.