feat: initial commit
This commit is contained in:
commit
e214116e40
253 changed files with 17406 additions and 0 deletions
34
src/data/posts.js
Normal file
34
src/data/posts.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import EleventyFetch from "@11ty/eleventy-fetch";
|
||||
|
||||
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
|
||||
|
||||
const fetchAllPosts = async () => {
|
||||
try {
|
||||
return await EleventyFetch(
|
||||
`${POSTGREST_URL}/optimized_posts?select=*&order=date.desc`,
|
||||
{
|
||||
duration: "1d",
|
||||
type: "json",
|
||||
fetchOptions: {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${POSTGREST_API_KEY}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error fetching posts:", error);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export default async function () {
|
||||
const posts = await fetchAllPosts();
|
||||
|
||||
return {
|
||||
all: posts,
|
||||
feed: posts.filter((posts) => posts.feed),
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue