From b697dead84e910ebda66034380191773ec2db70e Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 01:54:17 +0800 Subject: [PATCH 1/6] feat(Layout): Make ogImage an optional parameter --- src/layouts/Layout.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b340559fb2ab8ffb38c05246b527cfbc5b6aceb0 Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 01:55:07 +0800 Subject: [PATCH 2/6] feat(pages): Add 404 page and homepage description --- src/pages/404.astro | 26 ++++++++++++++++++++++++++ src/pages/index.astro | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/pages/404.astro diff --git a/src/pages/404.astro b/src/pages/404.astro new file mode 100644 index 0000000..e7f5736 --- /dev/null +++ b/src/pages/404.astro @@ -0,0 +1,26 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const url = new URL(Astro.url); +const notFoundPath = url.pathname +--- + + +

command not found.

+ +
+

sh: ~{notFoundPath}: 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/index.astro b/src/pages/index.astro index 79733f8..9b27c3b 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,9 +3,8 @@ import Layout from '../layouts/Layout.astro'; --- - +

~/

-
Not much here yet, but you can check out my blog posts here.
From 5a2abc1d110c7bc2272b86ae9b457ab970b72509 Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 01:57:38 +0800 Subject: [PATCH 3/6] feat(index): Add welcome heading --- src/pages/index.astro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/index.astro b/src/pages/index.astro index 9b27c3b..f8bda82 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -6,6 +6,8 @@ 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. From b110b042737dfd80ecea2886840c944c1d96f43c Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 10:10:16 +0800 Subject: [PATCH 4/6] fix(404): Simplify path retrieval logic --- src/pages/404.astro | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/404.astro b/src/pages/404.astro index e7f5736..c73b661 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -1,15 +1,14 @@ --- import Layout from '../layouts/Layout.astro'; -const url = new URL(Astro.url); -const notFoundPath = url.pathname +const url = Astro.url.pathname ---

command not found.

-

sh: ~{notFoundPath}: command not found.

+

sh: ~{url}: command not found.

help From e70d243e450bbbceba9d35c49354b9d66d8b6d83 Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 11:37:18 +0800 Subject: [PATCH 5/6] feat(llms): Add Markdown format content export feature --- src/pages/llms.txt.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/pages/llms.txt.js 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 }; +} From e002af6f8ad7bcc0d3a79441e79d61479a74aa64 Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sun, 18 May 2025 11:38:05 +0800 Subject: [PATCH 6/6] fix(blog): Add SEO description for the blog page --- src/pages/blog.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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