tahamajs/IE / Projects /front /src /components /blog /BlogSidebar.tsx
tahamajs's picture
download
raw
3.43 kB
// src/components/blog/BlogSidebar.tsx
import { Link } from "react-router-dom";
import { Search, TrendingUp, Calendar, User, Mail, Award } from "lucide-react";
import { BlogCategories } from "./BlogCategories";
import { BlogTags } from "./BlogTags";
import { BlogNewsletter } from "./BlogNewsletter";
import { BlogPost } from "@/types/blog";
interface BlogSidebarProps {
categories?: any[];
tags?: any[];
popularPosts?: BlogPost[];
showNewsletter?: boolean;
}
export function BlogSidebar({ categories, tags, popularPosts, showNewsletter = true }: BlogSidebarProps) {
return (
<div className="space-y-6">
{/* Search Widget */}
<div className="bg-white dark:bg-gray-800 rounded-2xl p-5 shadow-sm border border-gray-100 dark:border-gray-700">
<h3 className="font-semibold mb-3 flex items-center gap-2">
<Search className="h-4 w-4 text-primary" />
Search
</h3>
<div className="relative">
<input
type="text"
placeholder="Search articles..."
className="w-full rounded-xl border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900 px-4 py-2 pl-9 focus:outline-none focus:ring-2 focus:ring-primary"
/>
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
</div>
</div>
{/* Categories */}
{categories && categories.length > 0 && (
<BlogCategories categories={categories} />
)}
{/* Tags */}
{tags && tags.length > 0 && (
<BlogTags tags={tags} />
)}
{/* Popular Posts */}
{popularPosts && popularPosts.length > 0 && (
<div className="bg-white dark:bg-gray-800 rounded-2xl p-5 shadow-sm border border-gray-100 dark:border-gray-700">
<h3 className="font-semibold mb-3 flex items-center gap-2">
<TrendingUp className="h-4 w-4 text-primary" />
Popular Posts
</h3>
<div className="space-y-3">
{popularPosts.slice(0, 5).map((post) => (
<Link key={post.id} to={`/blog/${post.slug}`} className="flex gap-3 group">
<div className="w-16 h-16 rounded-lg overflow-hidden flex-shrink-0">
<img src={post.coverImage} alt={post.title} className="w-full h-full object-cover group-hover:scale-105 transition" />
</div>
<div className="flex-1 min-w-0">
<h4 className="text-sm font-medium line-clamp-2 group-hover:text-primary transition">{post.title}</h4>
<div className="text-xs text-gray-500 mt-1">{new Date(post.publishedAt ?? post.createdAt).toLocaleDateString()}</div>
</div>
</Link>
))}
</div>
</div>
)}
{/* Newsletter */}
{showNewsletter && <BlogNewsletter />}
{/* Author Stats */}
<div className="bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl p-5 text-center">
<Award className="h-8 w-8 text-primary mx-auto mb-2" />
<h3 className="font-semibold">Join Our Community</h3>
<p className="text-sm text-gray-500 mt-1">Get the latest research updates</p>
<Link to="/register" className="mt-3 inline-block rounded-full bg-primary px-4 py-1.5 text-sm text-white hover:bg-primary/90 transition">
Sign Up Free
</Link>
</div>
</div>
);
}

Xet Storage Details

Size:
3.43 kB
·
Xet hash:
afcc1933cfffca5a9aaef472bee0e41f768dc1520009beff4d92be7b7e83ab77

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.