My personal photography website steve.phot
portfolio photography svelte sveltekit
at main 32 lines 920 B view raw
1import type { ImageItem } from "$lib/types"; 2 3const R2_BASE_URL = "https://r2.steve.photo"; 4 5export async function getPhotos(platform: App.Platform | undefined): Promise<ImageItem[]> { 6 const db = platform?.env?.DB; 7 8 if (!db) { 9 return []; 10 } 11 12 const result = await db.prepare("SELECT * FROM photos ORDER BY date DESC").all(); 13 14 const photos: ImageItem[] = result.results.map((row: Record<string, unknown>) => ({ 15 slug: row.slug as string, 16 title: row.title as string, 17 date: row.date as string, 18 image: `${R2_BASE_URL}/${row.image_key}`, 19 thumb: `${R2_BASE_URL}/${row.thumb_key}`, 20 type: row.type as string, 21 camera: row.camera as string, 22 lens: row.lens as string, 23 aperture: row.aperture as string, 24 exposure: row.exposure as string, 25 focalLength: row.focal_length as string, 26 iso: row.iso as string, 27 make: row.make as string, 28 tags: [], 29 })); 30 31 return photos; 32}