Upgrades to Astro 5

This commit is contained in:
2024-12-24 09:26:32 +00:00
parent b080e56314
commit 532f75bea0
6 changed files with 2556 additions and 1734 deletions

4254
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,14 +8,14 @@
"astro": "cd website && astro"
},
"dependencies": {
"@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.1.2",
"astro": "^4.11.5",
"@astrojs/rss": "^4.0.10",
"@astrojs/sitemap": "^3.2.1",
"astro": "^5.1.1",
"markdown-it": "^14.1.0",
"typescript": "^5.4.3"
},
"devDependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/check": "^0.9.4",
"@types/markdown-it": "^14.1.1"
}
}

View File

@@ -1,8 +1,9 @@
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
schema: z.object({
loader: glob({ pattern: '**/*.(md|mdx|html)', base: './src/content/blog' }),
schema: z.object({
title: z.string(),
hidden: z.optional(z.boolean()),
description: z.string(),

View File

@@ -1,18 +1,18 @@
---
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}>

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',

View File

@@ -1,6 +1,11 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"strictNullChecks": true
}
"strictNullChecks": true
},
"include": [
".astro/types.d.ts",
"**/*"
],
"exclude": ["dist"]
}