feat: add daily vani
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Client for "Vāṇī of the Day" — the home page's daily content pick.
|
||||
*
|
||||
* Public endpoint (no auth): the BFF returns the same pick to everyone for the
|
||||
* current day, chosen from a prose chapter, verse, or transcript and not
|
||||
* repeated within 90 days.
|
||||
*/
|
||||
|
||||
const BFF_BASE = process.env.NEXT_PUBLIC_BFF_URL || "http://localhost:8080";
|
||||
|
||||
export type Vani = {
|
||||
kind: "verse" | "prose" | "transcript";
|
||||
label: string; // "Verse" | "Chapter" | "Lecture" | "Conversation"
|
||||
title: string;
|
||||
subtitle: string;
|
||||
href: string;
|
||||
book_title?: string;
|
||||
};
|
||||
|
||||
type Envelope<T> = { success?: boolean; data?: T };
|
||||
|
||||
export async function getVaniOfTheDay(): Promise<Vani | null> {
|
||||
try {
|
||||
const res = await fetch(`${BFF_BASE}/api/v1/vani/today`, {
|
||||
headers: { Accept: "application/json" },
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const body = (await res.json().catch(() => ({}))) as Envelope<Vani | null>;
|
||||
return body.data ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user