feat: migrated to Astro 6
All checks were successful
Test / npm test (push) Successful in 54s
Test / npm test (pull_request) Successful in 46s

This commit is contained in:
2026-04-09 08:47:37 +00:00
parent 12aa763b05
commit f90592d8a1
7 changed files with 17 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
--- ---
import { type CollectionEntry } from "astro:content"; import { type CollectionEntry, render } from "astro:content";
import dayjs from "dayjs"; import dayjs from "dayjs";
type Props = { type Props = {
@@ -7,7 +7,7 @@ type Props = {
}; };
const { post } = Astro.props; const { post } = Astro.props;
const { remarkPluginFrontmatter } = await post.render(); const { remarkPluginFrontmatter } = await render(post);
const formattedDate = dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY"); const formattedDate = dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY");
const datePublished = post.data.datePublished.toISOString(); const datePublished = post.data.datePublished.toISOString();
@@ -28,7 +28,7 @@ const datePublished = post.data.datePublished.toISOString();
<li> <li>
<article> <article>
<a href={`/blog/${post.slug}`} lang={post.data.lang}>{post.data.title}</a> <a href={`/blog/${post.id}`} lang={post.data.lang}>{post.data.title}</a>
<div> <div>
<small> <small>
<time datetime={datePublished} lang="en">{formattedDate}</time> <time datetime={datePublished} lang="en">{formattedDate}</time>

View File

@@ -27,7 +27,7 @@ const latestPosts = posts.slice(0, 5);
{ {
latestPosts.map((post) => ( latestPosts.map((post) => (
<li> <li>
<a href={`/blog/${post.slug}`} lang={post.data.lang}> <a href={`/blog/${post.id}`} lang={post.data.lang}>
{post.data.title} {post.data.title}
</a> </a>

View File

@@ -1,7 +1,9 @@
import { defineCollection, z } from "astro:content"; import { defineCollection } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
const blog = defineCollection({ const blog = defineCollection({
type: "content", loader: glob({ pattern: "**/*.md", base: "./src/content/blog" }),
schema: z.object({ schema: z.object({
basedOn: z.optional(z.string()), basedOn: z.optional(z.string()),
dateModified: z.coerce.date(), dateModified: z.coerce.date(),

View File

@@ -1,5 +1,5 @@
--- ---
import { type CollectionEntry, getCollection } from "astro:content"; import { type CollectionEntry, getCollection, render } from "astro:content";
import Comments from "../../components/Comments.astro"; import Comments from "../../components/Comments.astro";
import Layout from "../../layouts/BaseLayout.astro"; import Layout from "../../layouts/BaseLayout.astro";
import blogPostSchema from "../../utils/schemas/blogPostSchema"; import blogPostSchema from "../../utils/schemas/blogPostSchema";
@@ -13,20 +13,20 @@ export async function getStaticPaths() {
}); });
return posts.map((post) => ({ return posts.map((post) => ({
params: { slug: post.slug }, params: { slug: post.id },
props: post, props: post,
})); }));
} }
const post = Astro.props; const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render(); const { Content, remarkPluginFrontmatter } = await render(post);
const description = post.data.description; const description = post.data.description;
const isBasedOn = post.data.basedOn; const isBasedOn = post.data.basedOn;
const lang = post.data.lang; const lang = post.data.lang;
const preview = `/images/preview/${post.slug}.png`; const preview = `/images/preview/${post.id}.png`;
const slug = post.slug; const slug = post.id;
const title = post.data.title; const title = post.data.title;
const dateModified = post.data.dateModified?.toISOString(); const dateModified = post.data.dateModified?.toISOString();

View File

@@ -13,10 +13,9 @@ export async function GET(context) {
customData: `<language>en</language>`, customData: `<language>en</language>`,
description: description, description: description,
items: posts.map((post) => ({ items: posts.map((post) => ({
customData: post.data.customData,
description: post.data.description, description: post.data.description,
link: `/blog/${post.slug}`, link: `/blog/${post.id}`,
pubDate: post.data.pubDate, pubDate: post.data.datePublished,
title: post.data.title, title: post.data.title,
})), })),
site: context.site, site: context.site,

View File

@@ -19,7 +19,7 @@ export default ({ siteUrl, title, posts }: BlogSchemaParams): WithContext<Collec
"itemListElement": posts.map((post, index) => ({ "itemListElement": posts.map((post, index) => ({
"@type": "ListItem", "@type": "ListItem",
"position": index + 1, "position": index + 1,
"url": new URL(`/blog/${post.slug}`, siteUrl).toString(), "url": new URL(`/blog/${post.id}`, siteUrl).toString(),
"name": post.data.title, "name": post.data.title,
})), })),
}, },