Compare commits
7 commits
eeb3ccc656
...
d33b2be49e
Author | SHA1 | Date | |
---|---|---|---|
|
d33b2be49e | ||
|
e002af6f8a | ||
|
e70d243e45 | ||
|
b110b04273 | ||
|
5a2abc1d11 | ||
|
b340559fb2 | ||
|
b697dead84 |
5 changed files with 72 additions and 4 deletions
|
@ -10,7 +10,7 @@ interface Props {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
ogImage: string;
|
ogImage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultTitle = siteConfig.title
|
const defaultTitle = siteConfig.title
|
||||||
|
|
25
src/pages/404.astro
Normal file
25
src/pages/404.astro
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
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>
|
|
@ -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());
|
posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime());
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="Blog | Terminal Blog">
|
<Layout title="Blog | Terminal Blog" description="List all files and folders in the directory.">
|
||||||
<h1 class="title">~/blog</h1>
|
<h1 class="title">~/blog</h1>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
|
@ -3,10 +3,11 @@ import Layout from '../layouts/Layout.astro';
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="Home | Terminal Blog">
|
<Layout title="Home | Terminal Blog" description="That a good start.">
|
||||||
<h1 class="title">~/</h1>
|
<h1 class="title">~/</h1>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<h3>Welcome!</h3>
|
||||||
|
|
||||||
Not much here yet, but you can check out my blog posts <a href="/blog">here</a>.
|
Not much here yet, but you can check out my blog posts <a href="/blog">here</a>.
|
||||||
<br />
|
<br />
|
||||||
If you are site owner, please edit <code>src/pages/index.astro</code> to customize this page.
|
If you are site owner, please edit <code>src/pages/index.astro</code> to customize this page.
|
||||||
|
|
42
src/pages/llms.txt.js
Normal file
42
src/pages/llms.txt.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
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 };
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue