Fix Astro.glob deprecation warnings

Replace deprecated Astro.glob with import.meta.glob in all pages:
- src/pages/index.astro: Updated homepage to use import.meta.glob
- src/pages/blog/index.astro: Updated blog listing page
- Updated package.json with separate build commands

Changes use import.meta.glob with eager loading and properly extract
slugs from file paths for routing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Johannes Gasser
2026-01-28 17:52:36 +01:00
parent d70897a680
commit ac2d1f25e5
8 changed files with 121 additions and 7 deletions
+7 -3
View File
@@ -1,7 +1,11 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
const allPosts = await Astro.glob('../../../../content/blog/*.mdx');
const allPostFiles = import.meta.glob('../../../content/blog/*.mdx', { eager: true });
const allPosts = Object.entries(allPostFiles).map(([path, post]) => ({
...post,
slug: path.split('/').pop()?.replace('.mdx', '') || ''
}));
const sortedPosts = allPosts.sort(
(a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf()
);
@@ -30,7 +34,7 @@ const sortedPosts = allPosts.sort(
)}
<div class="post-content">
<h2>
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`}>
<a href={`/blog/${post.slug}`}>
{post.frontmatter.title}
</a>
</h2>
@@ -44,7 +48,7 @@ const sortedPosts = allPosts.sort(
</time>
</p>
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`} class="read-more">
<a href={`/blog/${post.slug}`} class="read-more">
Read full post →
</a>
</div>
+7 -3
View File
@@ -1,7 +1,11 @@
---
import BaseLayout from '../layouts/BaseLayout.astro';
const recentPosts = await Astro.glob('../../../content/blog/*.mdx');
const allPostFiles = import.meta.glob('../../content/blog/*.mdx', { eager: true });
const recentPosts = Object.entries(allPostFiles).map(([path, post]) => ({
...post,
slug: path.split('/').pop()?.replace('.mdx', '') || ''
}));
const sortedPosts = recentPosts
.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf())
.slice(0, 3);
@@ -44,7 +48,7 @@ const sortedPosts = recentPosts
{sortedPosts.map((post) => (
<article class="post-card">
<h3>
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`}>
<a href={`/blog/${post.slug}`}>
{post.frontmatter.title}
</a>
</h3>
@@ -56,7 +60,7 @@ const sortedPosts = recentPosts
})}
</p>
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`} class="read-more">
<a href={`/blog/${post.slug}`} class="read-more">
Read more →
</a>
</article>