update astro to v5

This commit is contained in:
2024-12-03 19:18:12 -07:00
parent 57df46dc07
commit 8a99507c2a
6 changed files with 760 additions and 1671 deletions

2408
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,15 +10,15 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.3.4",
"@astrojs/mdx": "^2.3.1",
"@astrojs/check": "^0.9.4",
"@astrojs/mdx": "^4.0.1",
"@astrojs/rss": "^4.0.9",
"@astrojs/sitemap": "^3.2.1",
"astro": "^4.16.14",
"astro": "^5.0.2",
"typescript": "^5.7.2"
},
"devDependencies": {
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.12.3"
"prettier": "^3.4.1",
"prettier-plugin-astro": "^0.14.1"
}
}

View File

@@ -1,7 +1,9 @@
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
// Load Markdown and MDX files in the `src/content/blog/` directory.
loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),

View File

@@ -1,18 +1,19 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
import {render} from 'astro:content';
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

@@ -94,7 +94,7 @@ const posts = (await getCollection("blog")).sort((a, b) =>
{
posts.map((post) => (
<li>
<a href={`/blog/${post.slug}/`}>
<a href={`/blog/${post.id}/`}>
{post.data.heroImage &&
<Image
width={720}

View File

@@ -10,7 +10,7 @@ export async function GET(context) {
site: context.site,
items: posts.map((post) => ({
...post.data,
link: `/blog/${post.slug}/`,
link: `/blog/${post.id}/`,
})),
});
}