28 lines
657 B
JavaScript
28 lines
657 B
JavaScript
import EleventyFetch from '@11ty/eleventy-fetch';
|
|
|
|
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
|
|
|
|
const fetchGlobals = async () => {
|
|
try {
|
|
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_globals?select=*`, {
|
|
duration: '1d',
|
|
type: 'json',
|
|
fetchOptions: {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Authorization: `Bearer ${POSTGREST_API_KEY}`
|
|
}
|
|
}
|
|
});
|
|
|
|
return data[0];
|
|
} catch (error) {
|
|
console.error('Error fetching globals:', error);
|
|
return {};
|
|
}
|
|
};
|
|
|
|
export default async function () {
|
|
return await fetchGlobals();
|
|
}
|