From 22e353c04c1d15805be93e6922b45e9372415d8f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 6 Jul 2026 21:53:18 -0400 Subject: update astro --- src/content.config.ts | 18 ++++++++++++++++++ src/content/config.ts | 16 ---------------- src/pages/blog/[...slug].astro | 4 ++-- src/pages/blog/index.astro | 2 +- src/pages/index.astro | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 src/content.config.ts delete mode 100644 src/content/config.ts (limited to 'src') diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..4ba5c7c --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,18 @@ +import { defineCollection } from "astro:content"; +import { z } from 'astro/zod'; +import { glob } from 'astro/loaders'; +import { rssSchema } from '@astrojs/rss'; + +const blogCollection = defineCollection({ + loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/blog" }), + schema: z.object({ + title: z.string(), + description: z.string(), + pubDate: z.date(), + tags: z.array(z.string()), + }), +}); + +export const collections = { + blog: blogCollection, +}; diff --git a/src/content/config.ts b/src/content/config.ts deleted file mode 100644 index 8dd2162..0000000 --- a/src/content/config.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { defineCollection, z } from "astro:content"; -import { rssSchema } from '@astrojs/rss'; - -const blogCollection = defineCollection({ - type: 'content', - schema: z.object({ - title: z.string(), - description: z.string(), - pubDate: z.date(), - tags: z.array(z.string()), - }), -}); - -export const collections = { - blog: blogCollection, -}; diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 5f1b34a..6dc78ba 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -1,6 +1,6 @@ --- import Page from '../../layouts/BlogPost.astro'; -import { getEntry } from 'astro:content'; +import { getEntry, render } from 'astro:content'; import { formatDate } from "../../util"; const { slug } = Astro.params; @@ -14,7 +14,7 @@ if(entry === undefined) { return Astro.redirect('/404'); } -const { Content } = await entry.render(); +const { Content } = await render(entry); ---
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index a35537a..0e4e25e 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -23,7 +23,7 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate
{allBlogPosts.map((post) => (
-

{post.data.title}

+

{post.data.title}

{formatDate(post.data.pubDate)}

{post.data.description}

diff --git a/src/pages/index.astro b/src/pages/index.astro index f1c2da9..943dc01 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -100,7 +100,7 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate

Latest Posts

{allBlogPosts.map((post) => ( -- cgit v1.2.3