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:
@@ -30,6 +30,5 @@ remarkPlugins[1][1].resolveEmbedContent = resolveEmbedContent;
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'https://wiki.bincio.com',
|
site: 'https://wiki.bincio.com',
|
||||||
integrations: [sitemap(), tailwind(), svelte()],
|
integrations: [sitemap(), tailwind(), svelte()],
|
||||||
legacy: { collections: true },
|
|
||||||
markdown: { remarkPlugins },
|
markdown: { remarkPlugins },
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+322
-1004
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -12,12 +12,12 @@
|
|||||||
"postinstall": "patch-package"
|
"postinstall": "patch-package"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/mdx": "^4.0.0",
|
"@astrojs/mdx": "^5.0.0",
|
||||||
"@astrojs/rss": "^4.0.0",
|
"@astrojs/rss": "^4.0.0",
|
||||||
"@astrojs/sitemap": "^3.2.0",
|
"@astrojs/sitemap": "^3.7.0",
|
||||||
"@astrojs/svelte": "^7.0.0",
|
"@astrojs/svelte": "^8.0.0",
|
||||||
"@astrojs/tailwind": "^5.1.0",
|
"@astrojs/tailwind": "^6.0.0",
|
||||||
"astro": "^5.0.0",
|
"astro": "^6.0.0",
|
||||||
"fast-glob": "^3.3.1",
|
"fast-glob": "^3.3.1",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"remark-caml": "^0.0.6-rm",
|
"remark-caml": "^0.0.6-rm",
|
||||||
|
|||||||
@@ -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 };
|
||||||
@@ -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 };
|
|
||||||
@@ -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';
|
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}>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const posts = (await getCollection('blog')).sort(
|
|||||||
{posts.map(post => (
|
{posts.map(post => (
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href={`/blog/${post.slug}/`}
|
href={`/blog/${post.id}/`}
|
||||||
class="block px-4 py-3 rounded-lg hover:bg-zinc-800 transition-colors group"
|
class="block px-4 py-3 rounded-lg hover:bg-zinc-800 transition-colors group"
|
||||||
style="background: var(--bg-card)"
|
style="background: var(--bg-card)"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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';
|
import Entry from '../../layouts/Entry.astro';
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const entries = await getCollection('entries');
|
const entries = await getCollection('entries');
|
||||||
return entries.map((entry) => ({
|
return entries.map((entry) => ({
|
||||||
params: { slug: entry.slug },
|
params: { slug: entry.id },
|
||||||
props: entry,
|
props: entry,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
type Props = CollectionEntry<'entries'>;
|
type Props = CollectionEntry<'entries'>;
|
||||||
|
|
||||||
const entry = Astro.props;
|
const entry = Astro.props;
|
||||||
const { Content, remarkPluginFrontmatter } = await entry.render();
|
const { Content, remarkPluginFrontmatter } = await render(entry);
|
||||||
entry.data.frontmatter = remarkPluginFrontmatter;
|
entry.data.frontmatter = remarkPluginFrontmatter;
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const entries = (await getCollection('entries'))
|
|||||||
{entries.map(entry => (
|
{entries.map(entry => (
|
||||||
<li>
|
<li>
|
||||||
<a
|
<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"
|
class="flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-zinc-800 transition-colors group"
|
||||||
style="background: var(--bg-card)"
|
style="background: var(--bg-card)"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export async function generateBlogBackRefs(thisFileName: string) {
|
|||||||
}
|
}
|
||||||
backattrs[typeStr].push({
|
backattrs[typeStr].push({
|
||||||
filenames: thatFName,
|
filenames: thatFName,
|
||||||
htmlHref: '/blog/' + thatDoc.slug,
|
htmlHref: '/blog/' + thatDoc.id,
|
||||||
htmlText: thatFName,
|
htmlText: thatFName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ export async function generateBlogBackRefs(thisFileName: string) {
|
|||||||
if (fnameStr === thisFileName) {
|
if (fnameStr === thisFileName) {
|
||||||
backlinks.push({
|
backlinks.push({
|
||||||
linktype: typeStr,
|
linktype: typeStr,
|
||||||
htmlHref: '/blog/' + thatDoc.slug,
|
htmlHref: '/blog/' + thatDoc.id,
|
||||||
htmlText: thatFName,
|
htmlText: thatFName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ export async function generateEntryBackRefs(thisFileName: string) {
|
|||||||
}
|
}
|
||||||
backattrs[typeStr].push({
|
backattrs[typeStr].push({
|
||||||
filenames: thatFName,
|
filenames: thatFName,
|
||||||
htmlHref: '/entries/' + thatDoc.slug,
|
htmlHref: '/entries/' + thatDoc.id,
|
||||||
htmlText: thatFName,
|
htmlText: thatFName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ export async function generateEntryBackRefs(thisFileName: string) {
|
|||||||
if (fnameStr === thisFileName) {
|
if (fnameStr === thisFileName) {
|
||||||
backlinks.push({
|
backlinks.push({
|
||||||
linktype: typeStr,
|
linktype: typeStr,
|
||||||
htmlHref: '/entries/' + thatDoc.slug,
|
htmlHref: '/entries/' + thatDoc.id,
|
||||||
htmlText: thatFName,
|
htmlText: thatFName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export async function buildBonsai(): Promise<SemTree | undefined> {
|
|||||||
for (const node of bonsai.nodes) {
|
for (const node of bonsai.nodes) {
|
||||||
const doc: any = allEntryDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
|
const doc: any = allEntryDocs.find((doc) => path.basename(doc.id, '.md') == node.text);
|
||||||
if (doc !== undefined) {
|
if (doc !== undefined) {
|
||||||
node.url = '/entries/' + doc.slug;
|
node.url = '/entries/' + doc.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// uncomment if 'virtualBranches' is set to 'false'
|
// uncomment if 'virtualBranches' is set to 'false'
|
||||||
|
|||||||
Reference in New Issue
Block a user