Added a terminal

This commit is contained in:
2025-06-04 00:47:42 -06:00
parent 5b2c4b0ede
commit 3347ec2082
4 changed files with 829 additions and 1 deletions

View File

@ -0,0 +1,42 @@
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 postsWithContent = await Promise.all(
posts.map(async (post) => {
const { Content } = await post.render();
// Get the raw markdown content by reading the file
const rawContent = post.body;
return {
slug: post.slug,
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate.toISOString().split('T')[0],
tags: post.data.tags || [],
content: rawContent
};
})
);
return new Response(JSON.stringify(postsWithContent), {
status: 200,
headers: {
'Content-Type': 'application/json'
}
});
} catch (error) {
console.error('Error fetching posts:', error);
return new Response(JSON.stringify([]), {
status: 500,
headers: {
'Content-Type': 'application/json'
}
});
}
};

25
src/pages/terminal.astro Normal file
View File

@ -0,0 +1,25 @@
---
import Layout from '../layouts/Layout.astro';
import TerminalComponent from '../components/Terminal.tsx';
import '../styles/global.css';
---
<Layout>
<div class="container mx-auto p-4 max-w-6xl w-full">
<div class="mb-4 text-center">
<h1 class="text-2xl font-bold mb-2">Shell Mode</h1>
<p class="text-base-content/70">Type 'help' to get started.</p>
</div>
<div class="h-[60vh] max-h-[500px] min-h-[400px]">
<TerminalComponent client:load />
</div>
</div>
</Layout>
<style>
/* Remove overflow hidden from body to allow normal scrolling */
html, body {
height: auto;
overflow: auto;
}
</style>