Compare commits

..

No commits in common. "d33b2be49e982b4fa2dfadc3ff93427792119eba" and "eeb3ccc656a6e138f6f5309d597d53d14eb6fced" have entirely different histories.

5 changed files with 4 additions and 72 deletions

View file

@ -10,7 +10,7 @@ interface Props {
title: string;
description: string;
path?: string;
ogImage?: string;
ogImage: string;
}
const defaultTitle = siteConfig.title

View file

@ -1,25 +0,0 @@
---
import Layout from '../layouts/Layout.astro';
const url = Astro.url.pathname
---
<Layout title="404 | Terminal Blog" description="Page not found">
<h1 class="title">command not found.</h1>
<div class="content">
<p class="typewriter">sh: <span class="path">~{url}</span>: command not found.</p>
<div style="margin-top: 2rem;">
<span class="command">help</span>
<div style="margin-top: 1rem; margin-left: 1rem;">
<p>
Looks like this is an unknown command or file, try:
</p>
<p>
<a href="/">Return to Home</a>
</p>
</div>
</div>
</div>
</Layout>

View file

@ -6,7 +6,7 @@ const posts = await getCollection('posts');
posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime());
---
<Layout title="Blog | Terminal Blog" description="List all files and folders in the directory.">
<Layout title="Blog | Terminal Blog">
<h1 class="title">~/blog</h1>
<div class="content">

View file

@ -3,11 +3,10 @@ import Layout from '../layouts/Layout.astro';
---
<Layout title="Home | Terminal Blog" description="That a good start.">
<Layout title="Home | Terminal Blog">
<h1 class="title">~/</h1>
<div class="content">
<h3>Welcome!</h3>
Not much here yet, but you can check out my blog posts <a href="/blog">here</a>.
<br />
If you are site owner, please edit <code>src/pages/index.astro</code> to customize this page.

View file

@ -1,42 +0,0 @@
import { getCollection } from "astro:content";
import { siteConfig } from "../config";
// Modified version that outputs markdown content
export async function GET(context) {
let baseUrl = context.site?.href || "https://terminal-blog.example.com";
if (baseUrl.at(-1) === "/") baseUrl = baseUrl.slice(0, -1);
const markdownText = `# ${siteConfig.title}
> ${siteConfig.description}
${await generateMarkdownSection("posts", "Post", baseUrl)}
${await generateMarkdownSection("pages", "Page", baseUrl)}`;
return new Response(markdownText);
}
async function generateMarkdownSection(collectionName, sectionTitle, baseUrl) {
const items = await getCollection(collectionName);
// Sort posts by pubDate if available
const sortedItems =
collectionName === "posts"
? items.sort((a, b) => (a.data.pubDate > b.data.pubDate ? -1 : 1))
: items;
let markdown = `## ${sectionTitle}\n`;
for (const item of sortedItems) {
const { title, description, slug } = getMetaData(item);
markdown += `\n- [${title}](${baseUrl}/post/${slug}): ${description}`;
}
return markdown;
}
function getMetaData(collection) {
const { title, description } = collection.data;
const { slug } = collection;
return { title, description, slug };
}