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" "astro": "cd website && astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/rss": "^4.0.5", "@astrojs/rss": "^4.0.10",
"@astrojs/sitemap": "^3.1.2", "@astrojs/sitemap": "^3.2.1",
"astro": "^4.11.5", "astro": "^5.1.1",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"typescript": "^5.4.3" "typescript": "^5.4.3"
}, },
"devDependencies": { "devDependencies": {
"@astrojs/check": "^0.5.10", "@astrojs/check": "^0.9.4",
"@types/markdown-it": "^14.1.1" "@types/markdown-it": "^14.1.1"
} }
} }

View File

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

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'; import BlogPost from '../../layouts/BlogPost.astro';
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getCollection('blog'); const posts = await getCollection('blog');
return posts.map((post) => ({ return posts.map((post) => ({
params: { slug: post.slug }, params: { slug: post.id },
props: post, props: post,
})); }));
} }
type Props = CollectionEntry<'blog'>; type Props = CollectionEntry<'blog'>;
const post = Astro.props; const post = Astro.props;
const { Content } = await post.render(); const { Content } = await render(post);
--- ---
<BlogPost {...post.data}> <BlogPost {...post.data}>
<Content /> <Content />
</BlogPost> </BlogPost>

View File

@@ -23,9 +23,9 @@ export async function GET(context: APIContext) {
site: path.join(site.toString(), 'blog'), site: path.join(site.toString(), 'blog'),
trailingSlash: false, trailingSlash: false,
items: posts.map((post) => ({ items: posts.map((post) => ({
link: `/blog/${post.slug}`, link: `/blog/${post.id}`,
title: post.data.title, title: post.data.title,
content: mdParser.render(post.body), content: mdParser.render(post.body ?? ''),
pubDate: post.data.pubDate, pubDate: post.data.pubDate,
description: post.data.description, description: post.data.description,
author: 'Joe Carstairs', author: 'Joe Carstairs',

View File

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