Spaces:
Sleeping
Sleeping
| export interface StoryCard { | |
| uid: string; | |
| name: string; | |
| slug: string; | |
| poster: string; | |
| year: number; | |
| location: string[]; | |
| media_type: string; | |
| awards: string[]; | |
| link: string; | |
| description: string; | |
| } | |
| export interface LandingStory { | |
| uid: string; | |
| name: string; | |
| slug: string; | |
| poster: string; | |
| year: number; | |
| media_type: string; | |
| awards_count: number; | |
| link: string; | |
| } | |
| export async function fetchStories(): Promise<LandingStory[]> { | |
| const resp = await fetch("/api/stories"); | |
| const data = await resp.json(); | |
| return data.stories; | |
| } | |
| export async function searchStories(query: string): Promise<StoryCard[]> { | |
| const resp = await fetch("/api/search", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ query }), | |
| }); | |
| if (!resp.ok) { | |
| throw new Error(`Search failed: ${resp.status}`); | |
| } | |
| const data = await resp.json(); | |
| return data.stories; | |
| } | |