feat: vani of the day

This commit is contained in:
gosangam
2026-08-31 13:40:08 +05:30
parent 53e00863f7
commit 082815fc53
2 changed files with 61 additions and 5 deletions
+16 -4
View File
@@ -535,14 +535,26 @@ export const vani = {
clear: (day: string) =>
call<void>(`/admin/vani/${encodeURIComponent(day)}`, { method: "DELETE" }),
/** Pin whatever an app link points at. The only reliable way to choose a
* specific item: slugs are not indexed, so searching one matches on its
* words instead ("720720sb-london" → anything mentioning London). */
setByURL: (input: { day: string; url: string }) =>
call<VaniPick>("/admin/vani/by-url", {
method: "POST",
body: JSON.stringify(input),
}).then((r) => r.data),
/**
* Search the three vāṇī-eligible collections. Uses the public search
* endpoint — the same index the app searches — and keeps only hits that map
* to a pinnable kind.
* Search the vāṇī-eligible collections.
*
* SCOPED server-side via `type`, not filtered here: `type=all` blends every
* collection and ranks by relevance, so the top hits are dominated by
* letters and glossary entries and a client-side filter throws the whole
* page away — which is exactly what made this look broken.
*/
search: async (q: string): Promise<VaniCandidate[]> => {
const { data } = await call<{ results: VaniCandidate[] }>(
`/search?type=all&limit=20&q=${encodeURIComponent(q)}`,
`/search?type=verses,prose,transcriptions&limit=20&q=${encodeURIComponent(q)}`,
);
return (data?.results ?? []).filter(
(r) => r.doc_id && vaniKindFor(r.collection),