fix(pagefind): case where baseUrl/bundleUrl not auto detected

See https://discord.com/channels/722225264733716590/1246693780191449159/1246693780191449159
This commit is contained in:
George Cushen 2024-06-02 14:10:52 +01:00
commit f78044d2b4

View file

@ -15,6 +15,9 @@
{{ $pf_js = $pf_js | resources.Fingerprint "sha256" }}
<script src="{{ $pf_js.RelPermalink }}" integrity="{{ $pf_js.Data.Integrity }}"></script>
{{ $search_config := dict "baseUrl" (relURL "") }}
{{ printf "<script>window.hbb.pagefind = %s;</script>" ($search_config | jsonify) | safeHTML }}
<style>
html.dark {
--pagefind-ui-primary: #eeeeee;
@ -27,7 +30,12 @@
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
new PagefindUI({
element: "#search",
showSubResults: true,
baseUrl: window.hbb.pagefind.baseUrl,
bundlePath: window.hbb.pagefind.baseUrl + "pagefind/",
});
});
document.addEventListener('DOMContentLoaded', () => {
let element = document.getElementById('search');