add some basic search functionality

This commit is contained in:
2024-07-15 04:30:05 +02:00
parent 55257f3bb4
commit c935314c4f
16 changed files with 226 additions and 5 deletions
+10
View File
@@ -27,6 +27,16 @@ export const PIG_NAMES = [
"peek",
];
export function getSearchPath(query: string): string {
const params = new URLSearchParams();
if (query) {
params.set("q", query);
} else {
params.delete("q");
}
return `/sok?${params.toString()}`;
}
export function randomElement(array: any[]): any | undefined {
return array.length
? array[Math.floor(Math.random() * array.length)]