Skip to content

Commit

Permalink
Added transformItems to remove the base url from the link of an Algol…
Browse files Browse the repository at this point in the history
…ia Search Hit
  • Loading branch information
r100-stack committed Aug 1, 2023
1 parent 232ed8c commit 3236957
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/website/src/components/AlgoliaSearch.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
apiKey: import.meta.env.PUBLIC_ALGOLIA_API_KEY,
indexName: import.meta.env.PUBLIC_ALGOLIA_INDEX_NAME,
container: 'algolia-searchbox',
// debug: false, // Set debug to true if you want to inspect the modal
transformItems: (items) => {
return items.map((item) => {
// Absolute URL -> Relative URL to work better on localhost, preview URLs, etc.
const url = new URL(item.url);
return {
...item,
url: url.href.replace(url.origin, ''),
};
});
},
});
</script>

Expand Down

0 comments on commit 3236957

Please sign in to comment.