Updated nav a bit
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m35s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m35s
This commit is contained in:
@@ -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",
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user