import type { Example, Project } from './types'; const isStatic = import.meta.env.VITE_STATIC_DATA === 'true'; async function read(name: string, signal: AbortSignal): Promise { const url = isStatic ? `./api/${name}.json` : `/api/${name}`; const response = await fetch(url, { signal }); if (!response.ok) throw new Error('Project content could not be loaded. Please try again.'); return response.json() as Promise; } export const api = { project: (signal: AbortSignal) => read('project', signal), example: (signal: AbortSignal) => read('example', signal), };