wip
This commit is contained in:
@@ -2,58 +2,70 @@ import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { getAllPosts } from '@/lib/blog';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { Section, Container } from '../../components/ui';
|
||||
import { Section, Container, Heading, Card, Badge } from '../../components/ui';
|
||||
|
||||
interface RecentPostsProps {
|
||||
locale: string;
|
||||
}
|
||||
|
||||
export default async function RecentPosts({ locale }: RecentPostsProps) {
|
||||
const t = await getTranslations('Footer'); // Reusing recentPosts title from Footer or Index
|
||||
const posts = await getAllPosts(locale);
|
||||
const recentPosts = posts.slice(0, 3);
|
||||
|
||||
if (recentPosts.length === 0) return null;
|
||||
|
||||
return (
|
||||
<Section className="bg-neutral-light py-24">
|
||||
<Section className="bg-neutral py-24">
|
||||
<Container>
|
||||
<div className="flex items-center justify-between mb-12">
|
||||
<h2 className="text-3xl md:text-4xl font-bold text-text-primary">
|
||||
<div className="flex flex-col md:flex-row items-end justify-between mb-16 gap-6">
|
||||
<Heading level={2} subtitle="Insights" className="mb-0">
|
||||
{locale === 'de' ? 'Aktuelle Blogbeiträge' : 'Recent Blog Posts'}
|
||||
</h2>
|
||||
<Link href={`/${locale}/blog`} className="text-primary font-bold hover:underline">
|
||||
{locale === 'de' ? 'Alle Beiträge ansehen' : 'View all posts'} →
|
||||
</Heading>
|
||||
<Link href={`/${locale}/blog`} className="group flex items-center text-primary font-bold text-lg">
|
||||
{locale === 'de' ? 'Alle Beiträge ansehen' : 'View all posts'}
|
||||
<span className="ml-2 transition-transform group-hover:translate-x-2">→</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-10">
|
||||
{recentPosts.map((post) => (
|
||||
<Link key={post.slug} href={`/${locale}/blog/${post.slug}`} className="group block bg-white rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all border border-neutral">
|
||||
{post.frontmatter.featuredImage && (
|
||||
<div className="relative h-48 overflow-hidden">
|
||||
<img
|
||||
src={post.frontmatter.featuredImage}
|
||||
alt={post.frontmatter.title}
|
||||
className="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
||||
/>
|
||||
<Link key={post.slug} href={`/${locale}/blog/${post.slug}`} className="group block">
|
||||
<Card className="h-full flex flex-col border-none shadow-lg hover:shadow-2xl transition-all duration-500">
|
||||
{post.frontmatter.featuredImage && (
|
||||
<div className="relative h-64 overflow-hidden">
|
||||
<img
|
||||
src={post.frontmatter.featuredImage}
|
||||
alt={post.frontmatter.title}
|
||||
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-primary-dark/60 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500" />
|
||||
{post.frontmatter.category && (
|
||||
<Badge variant="accent" className="absolute top-4 left-4 shadow-md">
|
||||
{post.frontmatter.category}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="p-8 flex flex-col flex-grow">
|
||||
<div className="text-sm font-medium text-text-light mb-4 flex items-center gap-2">
|
||||
<span className="w-8 h-px bg-neutral-medium" />
|
||||
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
})}
|
||||
</div>
|
||||
<h3 className="text-2xl font-bold text-primary group-hover:text-accent-dark transition-colors line-clamp-2 mb-6 leading-tight">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<div className="mt-auto flex items-center text-primary font-bold group-hover:underline decoration-2 underline-offset-4">
|
||||
{locale === 'de' ? 'Weiterlesen' : 'Read more'}
|
||||
<svg className="ml-2 w-5 h-5 transition-transform group-hover:translate-x-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="p-6">
|
||||
<div className="text-xs text-text-secondary mb-2">
|
||||
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
})}
|
||||
</div>
|
||||
<h3 className="text-xl font-bold text-text-primary group-hover:text-primary transition-colors line-clamp-2 mb-4">
|
||||
{post.frontmatter.title}
|
||||
</h3>
|
||||
<span className="text-primary text-sm font-bold inline-flex items-center">
|
||||
{locale === 'de' ? 'Weiterlesen' : 'Read more'} →
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user