Compare commits

...

7 commits

Author SHA1 Message Date
草方块
d33b2be49e
Merge pull request #1 from conglinyizhi/master 2025-05-18 12:31:28 +08:00
conglinyizhi
e002af6f8a fix(blog): Add SEO description for the blog page 2025-05-18 11:38:05 +08:00
conglinyizhi
e70d243e45 feat(llms): Add Markdown format content export feature 2025-05-18 11:37:18 +08:00
conglinyizhi
b110b04273 fix(404): Simplify path retrieval logic 2025-05-18 10:10:16 +08:00
conglinyizhi
5a2abc1d11 feat(index): Add welcome heading 2025-05-18 01:57:38 +08:00
conglinyizhi
b340559fb2 feat(pages): Add 404 page and homepage description 2025-05-18 01:55:07 +08:00
conglinyizhi
b697dead84 feat(Layout): Make ogImage an optional parameter 2025-05-18 01:54:17 +08:00
5 changed files with 72 additions and 4 deletions

View file

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

25
src/pages/404.astro Normal file
View 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>

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">
<Layout title="Blog | Terminal Blog" description="List all files and folders in the directory.">
<h1 class="title">~/blog</h1>
<div class="content">

View file

@ -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>
<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.

42
src/pages/llms.txt.js Normal file
View 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 };
}