import EleventyFetch from "@11ty/eleventy-fetch"; const { POSTGREST_URL, POSTGREST_API_KEY } = process.env; const fetchAllLinks = async () => { try { return await EleventyFetch(`${POSTGREST_URL}/optimized_links?select=*`, { duration: "1h", type: "json", fetchOptions: { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${POSTGREST_API_KEY}` } } }); } catch (error) { console.error("Error fetching links:", error); return []; } }; export default async function () { const links = await fetchAllLinks(); return { all: links, feed: links.filter((links) => links.feed) }; }