diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/content.config.ts (renamed from src/content/config.ts) | 6 | ||||
| -rw-r--r-- | src/pages/blog/[...slug].astro | 4 | ||||
| -rw-r--r-- | src/pages/blog/index.astro | 2 | ||||
| -rw-r--r-- | src/pages/index.astro | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/src/content/config.ts b/src/content.config.ts index 8dd2162..4ba5c7c 100644 --- a/src/content/config.ts +++ b/src/content.config.ts @@ -1,8 +1,10 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from "astro:content"; +import { z } from 'astro/zod'; +import { glob } from 'astro/loaders'; import { rssSchema } from '@astrojs/rss'; const blogCollection = defineCollection({ - type: 'content', + loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/blog" }), schema: z.object({ title: z.string(), description: z.string(), 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); --- <Page title={entry.data.title} description={entry.data.description} pubDate={formatDate(entry.data.pubDate)} tags={entry.data.tags}> <main> 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 <div class="grid"> {allBlogPosts.map((post) => ( <article class="card"> - <h1><a href={`/blog/${post.slug}`}>{post.data.title}</a></h1> + <h1><a href={`/blog/${post.id}`}>{post.data.title}</a></h1> <small>{formatDate(post.data.pubDate)}</small> <p>{post.data.description}</p> <div class="tags"> 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 <h1>Latest Posts</h1> {allBlogPosts.map((post) => ( <article> - <h1 class="blog-title"><a href={`/blog/${post.slug}`}>{post.data.title}</a></h1> + <h1 class="blog-title"><a href={`/blog/${post.id}`}>{post.data.title}</a></h1> <small>{formatDate(post.data.pubDate)}</small> <p>{post.data.description}</p> </article> |
