Files
einfach-produktiv/app/components/Blog.tsx
T
Marco 35670126ca Wire up the blog section to Payload CMS instead of hardcoded posts
Blog.tsx now fetches the einfach-produktiv tenant's posts from the
shared Payload instance at build/render time (ISR, 60s revalidate),
via a small typed fetch helper in app/lib/payload.ts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-02 13:27:14 +00:00

118 lines
4.5 KiB
TypeScript

import Link from "next/link";
import { getBlogPosts } from "../lib/payload";
export async function Blog() {
const posts = await getBlogPosts(3);
if (posts.length === 0) return null;
const featured = { ...posts[0], href: `/blog/${posts[0].slug}` };
const secondary = posts
.slice(1, 3)
.map((post) => ({ ...post, href: `/blog/${post.slug}` }));
return (
<div id="blog" className="flex flex-col gap-[3rem] items-start pb-[4rem] w-full bg-[#f5f0e8]">
{/* Section header */}
<div className="flex flex-col gap-[0.5rem] items-start px-[5rem] w-full">
<p className="font-bold text-[#f6a701] text-[1.25rem]">
Neue Impulse
</p>
<p
className="font-semibold text-[#222221] text-[1.75rem] leading-normal"
style={{ fontFamily: "var(--font-lora)" }}
>
Gedanken, Methoden &amp; Impulse
</p>
</div>
{/* Posts grid */}
<div className="flex flex-col gap-[2.5rem] items-start px-[5rem] w-full">
{/* Featured post — thumbnail flush left, card clips with overflow-hidden */}
<div className="w-full border border-[#d9d9d9] rounded-xl overflow-hidden flex gap-3">
<div className="relative h-[220px] shrink-0 w-[60%]">
<img
alt=""
src={featured.thumbnail ?? undefined}
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
/>
</div>
<div className="flex flex-1 flex-col justify-between py-4 pr-4 min-w-0">
<div className="flex flex-col gap-3">
<div className="flex gap-2 items-center font-semibold text-[#777] text-[1rem] uppercase whitespace-nowrap">
<span>{featured.category}</span>
<span></span>
<span>{featured.readTime} Min</span>
</div>
<div className="flex flex-col gap-4 text-[#222221]">
<p
className="font-semibold text-[1.75rem] leading-normal"
style={{ fontFamily: "var(--font-lora)" }}
>
{featured.title}
</p>
<p className="font-normal text-[1rem] leading-6">
{featured.excerpt}
</p>
</div>
</div>
<Link
href={featured.href}
className="font-bold text-[1rem] text-[#222221] whitespace-nowrap hover:text-[#f6a701] transition-colors"
>
Zum Beitrag
</Link>
</div>
</div>
{/* Secondary posts — thumbnail with own rounded-xl, card py-2 only */}
<div className="flex gap-3 w-full">
{secondary.map((post) => (
<div
key={post.id}
className="flex-1 border border-[#d9d9d9] rounded-xl flex gap-3 h-[230px] items-center py-2"
>
{/* Thumbnail: own border-radius so it sits neatly inside the padded card */}
<div className="rounded-xl overflow-hidden shrink-0 h-full w-[14.7rem]">
<img
alt=""
src={post.thumbnail ?? undefined}
className="w-full h-full object-cover pointer-events-none"
/>
</div>
<div className="flex flex-1 flex-col justify-between h-full min-w-0 py-2 pr-2 text-[#222221]">
<div className="flex flex-col gap-3">
<div className="flex gap-2 items-center font-semibold text-[#777] text-[1rem] uppercase whitespace-nowrap">
<span>{post.category}</span>
<span></span>
<span>{post.readTime} Min</span>
</div>
<div className="flex flex-col gap-4">
<p
className="font-semibold text-[1.25rem] leading-normal"
style={{ fontFamily: "var(--font-lora)" }}
>
{post.title}
</p>
<p className="font-normal text-[1rem] leading-6">
{post.excerpt}
</p>
</div>
</div>
<Link
href={post.href}
className="font-bold text-[1rem] whitespace-nowrap hover:text-[#f6a701] transition-colors"
>
Zum Beitrag
</Link>
</div>
</div>
))}
</div>
</div>
</div>
);
}