switch from tinacms to sanity

This commit is contained in:
2026-05-07 09:36:34 +02:00
parent bd97af838d
commit bf04f8679d
30 changed files with 10345 additions and 23187 deletions
+12 -16
View File
@@ -1,14 +1,10 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import { sanityClient } from '../../sanity/client';
import { urlFor } from '../../sanity/imageUrl';
import { allPostsQuery } from '../../sanity/queries';
const allPostFiles = import.meta.glob<{ frontmatter: Record<string, any> }>('../../../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()
);
const allPosts = await sanityClient.fetch(allPostsQuery);
---
<BaseLayout title="Blog" description="Latest news and updates from Theater Ziefen">
@@ -21,33 +17,33 @@ const sortedPosts = allPosts.sort(
<div class="blog-content">
<div class="container">
{sortedPosts.length === 0 ? (
{allPosts.length === 0 ? (
<p class="no-posts">No blog posts yet. Check back soon!</p>
) : (
<div class="posts-list">
{sortedPosts.map((post) => (
{allPosts.map((post: any) => (
<article class="post-item">
{post.frontmatter.coverImage && (
{post.coverImage && (
<div class="post-image">
<img src={post.frontmatter.coverImage} alt={post.frontmatter.title} />
<img src={urlFor(post.coverImage)} alt={post.title} />
</div>
)}
<div class="post-content">
<h2>
<a href={`/blog/${post.slug}`}>
{post.frontmatter.title}
{post.title}
</a>
</h2>
<p class="post-meta">
<time datetime={post.frontmatter.date}>
{new Date(post.frontmatter.date).toLocaleDateString('de-DE', {
<time datetime={post.date}>
{new Date(post.date).toLocaleDateString('de-DE', {
year: 'numeric',
month: 'long',
day: 'numeric'
})}
</time>
</p>
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
<p class="post-excerpt">{post.excerpt}</p>
<a href={`/blog/${post.slug}`} class="read-more">
Read full post →
</a>