Upgrades to Astro 5
This commit is contained in:
4254
package-lock.json
generated
4254
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(),
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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"]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user