diff options
| author | Valentin Popov <valentin@popov.link> | 2026-04-09 11:47:37 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-04-09 11:47:37 +0300 |
| commit | f90592d8a106bea418cbd3d8bce9c2d86029f93c (patch) | |
| tree | b5e4bc36e8b318641d34fd299911babf87b7e5d1 | |
| parent | 12aa763b05e0d5d903e77022afafc6d4bfccad9e (diff) | |
| download | popov.link-f90592d8a106bea418cbd3d8bce9c2d86029f93c.tar.xz popov.link-f90592d8a106bea418cbd3d8bce9c2d86029f93c.zip | |
feat: migrated to Astro 6
| -rw-r--r-- | renovate.config.cjs | 2 | ||||
| -rw-r--r-- | src/components/PostElement.astro | 6 | ||||
| -rw-r--r-- | src/components/Sections/LatestPosts.astro | 2 | ||||
| -rw-r--r-- | src/content.config.ts (renamed from src/content/config.ts) | 6 | ||||
| -rw-r--r-- | src/pages/blog/[...slug].astro | 10 | ||||
| -rw-r--r-- | src/pages/feed.xml.js | 5 | ||||
| -rw-r--r-- | src/utils/schemas/blogSchema.ts | 2 |
7 files changed, 17 insertions, 16 deletions
diff --git a/renovate.config.cjs b/renovate.config.cjs index 9d56531..ad40350 100644 --- a/renovate.config.cjs +++ b/renovate.config.cjs @@ -3,4 +3,4 @@ module.exports = { gitAuthor: "renovate[bot] <renovatebot@noreply.localhost>", optimizeForDisabled: true, platform: "gitea", -};
\ No newline at end of file +}; diff --git a/src/components/PostElement.astro b/src/components/PostElement.astro index 8b4b7c4..051a8ff 100644 --- a/src/components/PostElement.astro +++ b/src/components/PostElement.astro @@ -1,5 +1,5 @@ --- -import { type CollectionEntry } from "astro:content"; +import { type CollectionEntry, render } from "astro:content"; import dayjs from "dayjs"; type Props = { @@ -7,7 +7,7 @@ type 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 datePublished = post.data.datePublished.toISOString(); @@ -28,7 +28,7 @@ const datePublished = post.data.datePublished.toISOString(); <li> <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> <small> <time datetime={datePublished} lang="en">{formattedDate}</time> diff --git a/src/components/Sections/LatestPosts.astro b/src/components/Sections/LatestPosts.astro index e514ff5..5c6afd9 100644 --- a/src/components/Sections/LatestPosts.astro +++ b/src/components/Sections/LatestPosts.astro @@ -27,7 +27,7 @@ const latestPosts = posts.slice(0, 5); { latestPosts.map((post) => ( <li> - <a href={`/blog/${post.slug}`} lang={post.data.lang}> + <a href={`/blog/${post.id}`} lang={post.data.lang}> {post.data.title} </a> diff --git a/src/content/config.ts b/src/content.config.ts index 4277edc..189848c 100644 --- a/src/content/config.ts +++ b/src/content.config.ts @@ -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({ - type: "content", + loader: glob({ pattern: "**/*.md", base: "./src/content/blog" }), schema: z.object({ basedOn: z.optional(z.string()), dateModified: z.coerce.date(), diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index d12ff05..3bd2c61 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -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 Layout from "../../layouts/BaseLayout.astro"; import blogPostSchema from "../../utils/schemas/blogPostSchema"; @@ -13,20 +13,20 @@ export async function getStaticPaths() { }); return posts.map((post) => ({ - params: { slug: post.slug }, + params: { slug: post.id }, props: post, })); } const post = Astro.props; -const { Content, remarkPluginFrontmatter } = await post.render(); +const { Content, remarkPluginFrontmatter } = await render(post); const description = post.data.description; const isBasedOn = post.data.basedOn; const lang = post.data.lang; -const preview = `/images/preview/${post.slug}.png`; -const slug = post.slug; +const preview = `/images/preview/${post.id}.png`; +const slug = post.id; const title = post.data.title; const dateModified = post.data.dateModified?.toISOString(); diff --git a/src/pages/feed.xml.js b/src/pages/feed.xml.js index 7c41b4f..5aea78b 100644 --- a/src/pages/feed.xml.js +++ b/src/pages/feed.xml.js @@ -13,10 +13,9 @@ export async function GET(context) { customData: `<language>en</language>`, description: description, items: posts.map((post) => ({ - customData: post.data.customData, description: post.data.description, - link: `/blog/${post.slug}`, - pubDate: post.data.pubDate, + link: `/blog/${post.id}`, + pubDate: post.data.datePublished, title: post.data.title, })), site: context.site, diff --git a/src/utils/schemas/blogSchema.ts b/src/utils/schemas/blogSchema.ts index 77f4632..196f037 100644 --- a/src/utils/schemas/blogSchema.ts +++ b/src/utils/schemas/blogSchema.ts @@ -19,7 +19,7 @@ export default ({ siteUrl, title, posts }: BlogSchemaParams): WithContext<Collec "itemListElement": posts.map((post, index) => ({ "@type": "ListItem", "position": index + 1, - "url": new URL(`/blog/${post.slug}`, siteUrl).toString(), + "url": new URL(`/blog/${post.id}`, siteUrl).toString(), "name": post.data.title, })), }, |
