Overview
TheCardsBlog component displays blog posts in a responsive card grid with built-in search functionality. It queries published posts from the blog collection and renders them with styled cards.
Features
- Automatic Post Loading - Fetches and displays published blog posts from content collections
- Search Functionality - Filter posts by title, description, or tags
- Responsive Grid - Adapts from 1 column (mobile) to 3 columns (desktop)
- Hover Effects - Smooth animations on card hover
- Tag Display - Shows post tags as styled badges
- Date Formatting - Displays post creation date in readable format
- Empty State - Shows message when no posts are published or found
Source Code
src/components/Blog/CardsBlog.astro
Usage
The CardsBlog component is primarily used on the blog index page to display all published posts:src/pages/blog/index.astro
Search Functionality
The component includes a built-in search script that filters posts:Search Implementation
- Post title
- Post description
- Post tags
Styling
The component uses a dark gradient background matching the site theme:Card Styling Details
Card Styling Details
- Background: Linear gradient from
#003553to#001a29 - Border: Subtle blue border with
rgba(2, 129, 198, 0.2) - Hover Effect: Lifts card with
translateY(-5px)and enhances shadow - Border Radius:
15pxfor smooth corners - Badge Color:
#0281C6(blue accent)
Responsive Behavior
The grid adapts to screen size:| Breakpoint | Columns | Width |
|---|---|---|
| Mobile (< 768px) | 1 | 100% |
| Tablet (768px+) | 2 | 50% |
| Desktop (1200px+) | 3 | 33.33% |
Empty States
- No Published Posts
- No Search Results
When no posts have
publish: true, displays:Post Data Structure
Each post card displays data from the blog collection schema:Related Components
Blog System
Learn about the complete blog architecture
Content Collections
Understand how blog posts are structured
