Updated nav a bit
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m35s

This commit is contained in:
2026-01-24 18:57:44 -07:00
parent d3844a5870
commit 09fdbf7ec7
7 changed files with 69 additions and 83 deletions

View File

@@ -1,33 +1,32 @@
import { getCollection } from 'astro:content';
import type { APIRoute } from 'astro';
import { getCollection } from "astro:content";
import type { APIRoute } from "astro";
export const GET: APIRoute = async () => {
try {
const posts = await getCollection('posts');
// Get the raw content from each post
const posts = await getCollection("posts");
const postsWithContent = posts.map((post) => ({
slug: post.slug,
slug: post.id,
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate.toISOString().split('T')[0],
pubDate: post.data.pubDate.toISOString().split("T")[0],
tags: post.data.tags || [],
content: post.body
content: post.body,
}));
return new Response(JSON.stringify(postsWithContent), {
status: 200,
headers: {
'Content-Type': 'application/json'
}
"Content-Type": "application/json",
},
});
} catch (error) {
console.error('Error fetching posts:', error);
console.error("Error fetching posts:", error);
return new Response(JSON.stringify([]), {
status: 500,
headers: {
'Content-Type': 'application/json'
}
"Content-Type": "application/json",
},
});
}
};
};