This commit is contained in:
Joe Carstairs
2025-01-28 18:06:53 +00:00
19 changed files with 2940 additions and 1748 deletions
+4 -4
View File
@@ -1,20 +1,20 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import { type CollectionEntry, getCollection, render } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug },
params: { slug: post.id },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
const post = Astro.props;
const { Content } = await post.render();
const { Content } = await render(post);
---
<BlogPost {...post.data}>
<Content />
</BlogPost>
</BlogPost>
+2 -2
View File
@@ -23,9 +23,9 @@ export async function GET(context: APIContext) {
site: path.join(site.toString(), 'blog'),
trailingSlash: false,
items: posts.map((post) => ({
link: `/blog/${post.slug}`,
link: `/blog/${post.id}`,
title: post.data.title,
content: mdParser.render(post.body),
content: mdParser.render(post.body ?? ''),
pubDate: post.data.pubDate,
description: post.data.description,
author: 'Joe Carstairs',