preselect search version filters

This commit is contained in:
outfoxxed 2026-04-03 00:27:50 -07:00
parent 8af645c093
commit 940e9e3f2c
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -133,7 +133,10 @@ import magnifierIcon from "@icons/magnifier.svg?raw";
//@ts-expect-error
"@pagefind/default-ui"
);
new PagefindUI({
const versionMatch = window.location.pathname.match(/^\/docs\/([^/]+)/);
const activeVersion = versionMatch?.[1];
const search = new PagefindUI({
element: "#qs_search",
// resetStyles: false,
sort: { version: "desc" },
@ -170,6 +173,10 @@ import magnifierIcon from "@icons/magnifier.svg?raw";
});
},
});
if (activeVersion) {
search.triggerFilters({ version: activeVersion });
}
});
});
}