Upgrade to Astro 6.1.9 and migrate to content layer API

Moves content config from src/content/config.ts to src/content.config.ts
with glob loaders as required by Astro 6. Replaces entry.slug with entry.id
and entry.render() with render(entry) throughout. Removes legacy collections
option from astro.config.mjs.
This commit is contained in:
brutsalvadi
2026-04-22 23:08:33 +02:00
parent e1e3b0a85b
commit 4ebc4c798c
11 changed files with 375 additions and 1055 deletions
-1
View File
@@ -30,6 +30,5 @@ remarkPlugins[1][1].resolveEmbedContent = resolveEmbedContent;
export default defineConfig({
site: 'https://wiki.bincio.com',
integrations: [sitemap(), tailwind(), svelte()],
legacy: { collections: true },
markdown: { remarkPlugins },
});
+322 -1004
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -12,12 +12,12 @@
"postinstall": "patch-package"
},
"dependencies": {
"@astrojs/mdx": "^4.0.0",
"@astrojs/mdx": "^5.0.0",
"@astrojs/rss": "^4.0.0",
"@astrojs/sitemap": "^3.2.0",
"@astrojs/svelte": "^7.0.0",
"@astrojs/tailwind": "^5.1.0",
"astro": "^5.0.0",
"@astrojs/sitemap": "^3.7.0",
"@astrojs/svelte": "^8.0.0",
"@astrojs/tailwind": "^6.0.0",
"astro": "^6.0.0",
"fast-glob": "^3.3.1",
"gray-matter": "^4.0.3",
"remark-caml": "^0.0.6-rm",
+35
View File
@@ -0,0 +1,35 @@
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const blog = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
schema: z.object({
title: z.string(),
description: z.string(),
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});
const entries = defineCollection({
loader: glob({
pattern: '**/*.md',
base: './src/content/entries',
generateId: ({ entry }) => entry.replace(/^_wiki\//, '').replace(/\.mdx?$/, ''),
}),
schema: z.object({
title: z.string(),
pubDate: z.coerce.date().optional(),
updatedDate: z.coerce.date().optional(),
}),
});
const index = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/index' }),
schema: z.object({
title: z.string(),
}),
});
export const collections = { blog, entries, index };
-32
View File
@@ -1,32 +0,0 @@
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
description: z.string(),
// Transform string to Date object
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});
const entries = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
// Transform string to Date object
pubDate: z.coerce.date().optional(),
updatedDate: z.coerce.date().optional(),
}),
});
const index = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
}),
});
export const collections = { blog, entries, index };
+3 -3
View File
@@ -1,18 +1,18 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import { type CollectionEntry, getCollection, render } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
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}>
+1 -1
View File
@@ -19,7 +19,7 @@ const posts = (await getCollection('blog')).sort(
{posts.map(post => (
<li>
<a
href={`/blog/${post.slug}/`}
href={`/blog/${post.id}/`}
class="block px-4 py-3 rounded-lg hover:bg-zinc-800 transition-colors group"
style="background: var(--bg-card)"
>
+3 -3
View File
@@ -1,18 +1,18 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import { type CollectionEntry, getCollection, render } from 'astro:content';
import Entry from '../../layouts/Entry.astro';
export async function getStaticPaths() {
const entries = await getCollection('entries');
return entries.map((entry) => ({
params: { slug: entry.slug },
params: { slug: entry.id },
props: entry,
}));
}
type Props = CollectionEntry<'entries'>;
const entry = Astro.props;
const { Content, remarkPluginFrontmatter } = await entry.render();
const { Content, remarkPluginFrontmatter } = await render(entry);
entry.data.frontmatter = remarkPluginFrontmatter;
---
+1 -1
View File
@@ -25,7 +25,7 @@ const entries = (await getCollection('entries'))
{entries.map(entry => (
<li>
<a
href={`/entries/${entry.slug}/`}
href={`/entries/${entry.id}/`}
class="flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-zinc-800 transition-colors group"
style="background: var(--bg-card)"
>
+4 -4
View File
@@ -38,7 +38,7 @@ export async function generateBlogBackRefs(thisFileName: string) {
}
backattrs[typeStr].push({
filenames: thatFName,
htmlHref: '/blog/' + thatDoc.slug,
htmlHref: '/blog/' + thatDoc.id,
htmlText: thatFName,
});
}
@@ -52,7 +52,7 @@ export async function generateBlogBackRefs(thisFileName: string) {
if (fnameStr === thisFileName) {
backlinks.push({
linktype: typeStr,
htmlHref: '/blog/' + thatDoc.slug,
htmlHref: '/blog/' + thatDoc.id,
htmlText: thatFName,
});
}
@@ -87,7 +87,7 @@ export async function generateEntryBackRefs(thisFileName: string) {
}
backattrs[typeStr].push({
filenames: thatFName,
htmlHref: '/entries/' + thatDoc.slug,
htmlHref: '/entries/' + thatDoc.id,
htmlText: thatFName,
});
}
@@ -101,7 +101,7 @@ export async function generateEntryBackRefs(thisFileName: string) {
if (fnameStr === thisFileName) {
backlinks.push({
linktype: typeStr,
htmlHref: '/entries/' + thatDoc.slug,
htmlHref: '/entries/' + thatDoc.id,
htmlText: thatFName,
});
}
+1 -1
View File
@@ -31,7 +31,7 @@ export async function buildBonsai(): Promise<SemTree | undefined> {
for (const node of bonsai.nodes) {
const doc: any = allEntryDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
if (doc !== undefined) {
node.url = '/entries/' + doc.slug;
node.url = '/entries/' + doc.id;
}
}
// uncomment if 'virtualBranches' is set to 'false'