33 lines
782 B
JavaScript
33 lines
782 B
JavaScript
import EleventyFetch from "@11ty/eleventy-fetch";
|
|
|
|
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
|
|
|
|
const fetchRecentMedia = async () => {
|
|
try {
|
|
const data = await EleventyFetch(
|
|
`${POSTGREST_URL}/optimized_recent_media?select=*`,
|
|
{
|
|
duration: "1h",
|
|
type: "json",
|
|
fetchOptions: {
|
|
method: "GET",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${POSTGREST_API_KEY}`,
|
|
},
|
|
},
|
|
},
|
|
);
|
|
|
|
const [{ recent_activity } = {}] = data;
|
|
|
|
return recent_activity || [];
|
|
} catch (error) {
|
|
console.error("Error fetching recent media data:", error);
|
|
return [];
|
|
}
|
|
};
|
|
|
|
export default async function () {
|
|
return await fetchRecentMedia();
|
|
}
|