diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b61d8fe..2717b54 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -10,7 +10,7 @@ interface Props { title: string; description: string; path?: string; - ogImage: string; + ogImage?: string; } const defaultTitle = siteConfig.title diff --git a/src/pages/404.astro b/src/pages/404.astro new file mode 100644 index 0000000..c73b661 --- /dev/null +++ b/src/pages/404.astro @@ -0,0 +1,25 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const url = Astro.url.pathname +--- + + +

command not found.

+ +
+

sh: ~{url}: command not found.

+ +
+ help +
+

+ Looks like this is an unknown command or file, try: +

+

+ Return to Home +

+
+
+
+
\ No newline at end of file diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 0e7f986..08c41a6 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -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()); --- - +

~/blog

diff --git a/src/pages/index.astro b/src/pages/index.astro index 79733f8..f8bda82 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,10 +3,11 @@ import Layout from '../layouts/Layout.astro'; --- - +

~/

-
+

Welcome!

+ Not much here yet, but you can check out my blog posts here.
If you are site owner, please edit src/pages/index.astro to customize this page. diff --git a/src/pages/llms.txt.js b/src/pages/llms.txt.js new file mode 100644 index 0000000..b917536 --- /dev/null +++ b/src/pages/llms.txt.js @@ -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 }; +}