File tree Expand file tree Collapse file tree 4 files changed +8
-7
lines changed
packages/astro-theme/components/search Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 55 export let productId: string | undefined ;
66 export let placeholder: string ;
77 export let locale: string ;
8+ export let baseUrl: string ;
89
910 let pagefind: Pagefind ;
1011 let results: PagefindResult [] = [];
1112 let noResultsForQuery = false ;
1213
1314 onMount (async () => {
14- const url =
15- productId === " cheerpj3"
16- ? new URL (window .origin + " /docs/pagefind/pagefind.js" ).href // Add /docs/ for CJ so search bar is able to link correctly
17- : new URL (window .origin + " /pagefind/pagefind.js" ).href ; // Can't use import.meta.url because Vite prefixes the module with /@fs.
15+ const url = new URL (window .origin + baseUrl + " pagefind/pagefind.js" ).href ;
1816 // @ts-ignore
1917 const pf = await import (/* @vite-ignore */ url );
2018 await pf .init ();
3533
3634 const response = await pagefind .debouncedSearch (query , {
3735 filters: { productId , language: locale },
38- baseUrl: import . meta . env . BASE_URL ,
36+ baseUrl ,
3937 });
4038 if (response === null ) {
4139 // Debounce.
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ import { t } from "../../lib/i18n";
88interface Props {
99 filterProductId? : Product | " blog" ; // data-pagefind-filter productId
1010}
11+
12+ const baseUrl = import .meta .env .BASE_URL || " /" ;
1113---
1214
1315<site-search class =" inline-block w-full h-10 max-w-full" >
@@ -35,6 +37,7 @@ interface Props {
3537 productId ={ Astro .props .filterProductId }
3638 placeholder ={ t (" Type to search..." , Astro .currentLocale )}
3739 locale ={ Astro .currentLocale }
40+ {baseUrl }
3841 >
3942 <div
4043 slot =" no-results"
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { resolve } from "node:path";
66// https://astro.build/config
77export default defineConfig ( {
88 site : "https://browserpod.io" ,
9- base : "/docs" ,
9+ base : "/docs/ " ,
1010 integrations : [
1111 icon ( ) ,
1212 theme ( {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { resolve } from "node:path";
66// https://astro.build/config
77export default defineConfig ( {
88 site : "https://cheerpj.com" ,
9- base : "/docs" ,
9+ base : "/docs/ " ,
1010 integrations : [
1111 icon ( ) ,
1212 theme ( {
You can’t perform that action at this time.
0 commit comments