返回 presentation-ai
pixabay.ts
根目录 / src / app / _actions / apps / image-studio / pixabay.ts
1 "use server";
2
3 type PixabayImage = {
4 url: string;
5 thumb?: string;
6 title?: string;
7 author?: string;
8 link?: string;
9 };
10
11 export async function searchPixabayImages(
12 _query: string,
13 ): Promise<{ success: boolean; images?: PixabayImage[]; error?: string }> {
14 return { success: true, images: [] };
15 }
16
17 export async function getTrendingPixabayImages(): Promise<{
18 success: boolean;
19 images?: PixabayImage[];
20 error?: string;
21 }> {
22 return { success: true, images: [] };
23 }
24
25 export async function getImageFromPixabay(
26 query: string,
27 _layoutType?: string,
28 ): Promise<{ success: boolean; imageUrl?: string; error?: string }> {
29 const result = await searchPixabayImages(query);
30 const firstImage = result.images?.[0];
31
32 if (!result.success || !firstImage?.url) {
33 return {
34 success: false,
35 error: result.error ?? "No Pixabay images found",
36 };
37 }
38
39 return {
40 success: true,
41 imageUrl: firstImage.url,
42 };
43 }
44
44 lines TYPESCRIPT