summaryrefslogtreecommitdiff
path: root/examples/blog
diff options
context:
space:
mode:
Diffstat (limited to 'examples/blog')
-rw-r--r--examples/blog/package.json4
-rw-r--r--examples/blog/src/content.config.ts (renamed from examples/blog/src/content/config.ts)4
-rw-r--r--examples/blog/src/pages/blog/[...slug].astro5
-rw-r--r--examples/blog/src/pages/blog/index.astro2
-rw-r--r--examples/blog/src/pages/rss.xml.js2
5 files changed, 10 insertions, 7 deletions
diff --git a/examples/blog/package.json b/examples/blog/package.json
index ddbe48af3..b62b24f52 100644
--- a/examples/blog/package.json
+++ b/examples/blog/package.json
@@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
- "@astrojs/mdx": "^3.1.9",
+ "@astrojs/mdx": "^4.0.0-beta.5",
"@astrojs/rss": "^4.0.9",
"@astrojs/sitemap": "^3.2.1",
- "astro": "^4.16.16"
+ "astro": "^5.0.0-beta.12"
}
}
diff --git a/examples/blog/src/content/config.ts b/examples/blog/src/content.config.ts
index 667a31cc7..7d92b1a3b 100644
--- a/examples/blog/src/content/config.ts
+++ b/examples/blog/src/content.config.ts
@@ -1,7 +1,9 @@
+import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
- type: 'content',
+ // Load Markdown and MDX files in the `src/content/blog/` directory.
+ loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
diff --git a/examples/blog/src/pages/blog/[...slug].astro b/examples/blog/src/pages/blog/[...slug].astro
index 07dbce26b..096bd1e82 100644
--- a/examples/blog/src/pages/blog/[...slug].astro
+++ b/examples/blog/src/pages/blog/[...slug].astro
@@ -1,18 +1,19 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
+import { render } from 'astro:content';
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}>
diff --git a/examples/blog/src/pages/blog/index.astro b/examples/blog/src/pages/blog/index.astro
index a1019da5b..1d8d02aa5 100644
--- a/examples/blog/src/pages/blog/index.astro
+++ b/examples/blog/src/pages/blog/index.astro
@@ -93,7 +93,7 @@ const posts = (await getCollection('blog')).sort(
{
posts.map((post) => (
<li>
- <a href={`/blog/${post.slug}/`}>
+ <a href={`/blog/${post.id}/`}>
<img width={720} height={360} src={post.data.heroImage} alt="" />
<h4 class="title">{post.data.title}</h4>
<p class="date">
diff --git a/examples/blog/src/pages/rss.xml.js b/examples/blog/src/pages/rss.xml.js
index 9ff9801e0..ae5e4c4ec 100644
--- a/examples/blog/src/pages/rss.xml.js
+++ b/examples/blog/src/pages/rss.xml.js
@@ -10,7 +10,7 @@ export async function GET(context) {
site: context.site,
items: posts.map((post) => ({
...post.data,
- link: `/blog/${post.slug}/`,
+ link: `/blog/${post.id}/`,
})),
});
}